|
From: Will D. <wi...@wj...> - 2008-06-14 16:42:41
|
On Jun 14, 2008, at 8:36 AM, Arnulf Wiedemann wrote: > Am Samstag, 14. Juni 2008 14:31:33 schrieb Donal K. Fellows: >> PROPOSED CHANGE >> ================= >> >> Every object and every class will have associated with it a list of >> variable names. This list will be configurable via a subcommand of >> *oo::define* and introspectable. Methods (strictly, only procedure- >> like >> methods, constructors and destructors) will then make those variables >> that were declared at the same declaration level (i.e. in the same >> class, or in the object itself for methods defined on the object) >> available in the method body without further declaration or >> qualification. At declaration time, the type of the variable (i.e. >> whether it is an array or a simple variable) will not be defined; >> that >> may be done in the constructor. As there is no (public) C API for >> declaring a procedure-like method, there will not be a public C API >> for >> declaring the variables either. >> > > First of all, thanks for starting a tip for variables for TclOO. > > I think I have not yet fully understood, how that will work. > > For example: > class cat has a variable cat_color defined and I have 2 objects > which have as > object class cat and these are named cat1 and cat2. Will variable > cat_color > be shared between the objects? > So if I set cat1 cat_color to black with a class method, will a > class method > of cat2 get back black as cat_color? > > Are object specific variables also accessible by class methods? I'm equally pleased to see this; thank you, Donal. I am curious about this point as well. As I read it, normal variables declared by class cat are instance variables; cat1 and cat2 do not share values. However, variables can also be declared by the class using "self"; in this case, the variable is a "typevariable" in Snit parlance. Is that correct? Will such class variables be visible without declaration or qualification in instance methods? (I'd presume so.) And I presume that class and instance variables declared by ancestors will also be accessible, but *with* qualification (mechanism clearly to be fleshed out later)? Will > > > Arnulf > >> Note that the order in which the declaration of some methods and some >> variables for a class or object will not matter. >> >> DECLARATION >> ------------- >> >> The *oo::define* and *oo::objdefine* (and also the *self* >> subcommand of >> *oo::define*) will gain a new subcommand: *variable*. This will take >> zero or more arguments, and those arguments will form the list of >> variables that are made available by default. Each argument will need >> to be a valid variable local name without parentheses. >> >> Syntax (other uses analogous according to normal behaviour of the >> class >> and object definition commands): >> >> *oo::define* /class/ *variable* ?/varName .../? >> >> INTROSPECTION >> --------------- >> >> The list of variables declared by a particular class, /class/, may be >> retrieved by: >> >> *info class variables* /class/ >> >> The list of variables declared by a particular object, /object/, >> may be >> retrieved by: >> >> *info object variables* /object/ >> >> Note that the full list of /all/ variables (matching an optional >> pattern) in an object's namespace will be retrievable using *info >> object vars*; this mechanism is disjoint (though *info object >> variables* will return variables that can be returned by *info object >> vars*). >> >> IMPLEMENTATION >> ================ >> >> Not yet done; details still to be written up here. >> >> COPYRIGHT >> =========== >> >> This document has been placed in the public domain. >> >> ------------------------------------------------------------------------- >> >> TIP AutoGenerator - written by Donal K. Fellows >> >> ------------------------------------------------------------------------- >> Check out the new SourceForge.net Marketplace. >> It's the best place to buy or sell services for >> just about anything Open Source. >> http://sourceforge.net/services/buy/index.php >> _______________________________________________ >> Tcl-Core mailing list >> Tcl...@li... >> https://lists.sourceforge.net/lists/listinfo/tcl-core > > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > Tcl-Core mailing list > Tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-core ------------------------------------------------------------------ will -at- wjduquette.com | Catch our weblog, http://foothills.wjduquette.com/blog | The View from the Foothills |