I'm proposing an object method "createAsChild", or something similar. The syntax would be:
createAsChild <class> ?arg0 arg1 ...?
This would basically be a convenience method to do the equivalent of creating an object as a child of another with the normal aggregation, plus using autoname. Ie the following two cases would be the same:
set nm [MyClass autoname MyClass] MyClass ${ob}::$nm foo bar
and
$ob createAsChild MyClass foo bar
Thus making it much easier to use aggregation with automatically created names. I'm not saying this is necessarily the best possible syntax for that: maybe it would be better to do "MyClass newAsChild $ob foo bar"? Anyway I only use autonaming myself for making instances of classes so this would be quite useful. Of course, with XOTcl I'm allowed the possibility of adding to the Object or Class objects myself which is fabulous. Just that it might be useful as a core element of the language.
As a matter of interest, how many people here only use objects created with autoname?
- ---------- = = ---------//--+ | / Kristoffer Lawson | www.fishpool.fi|.com +-> | setok@fishpool.com | - - --+------ |-- Fishpool Creations Ltd - / | +-------- = - - - = --------- /~setok/
On Sunday 27 May 2001 02:16, you wrote:
I'm proposing an object method "createAsChild", or something similar. The syntax would be:
createAsChild <class> ?arg0 arg1 ...?
This would basically be a convenience method to do the equivalent of creating an object as a child of another with the normal aggregation, plus using autoname. Ie the following two cases would be the same:
set nm [MyClass autoname MyClass] MyClass ${ob}::$nm foo bar
and
$ob createAsChild MyClass foo bar
Thus making it much easier to use aggregation with automatically created names. I'm not saying this is necessarily the best possible syntax for that: maybe it would be better to do "MyClass newAsChild $ob foo bar"? Anyway I only use autonaming myself for making instances of classes so this would be quite useful. Of course, with XOTcl I'm allowed the possibility of adding to the Object or Class objects myself which is fabulous. Just that it might be useful as a core element of the language.
Dear Kristoffer,
are you aware of the predefined methods "new" and "newChild" (the first one simplifies only the call to autoname, while the second one creates a new autonamed object as an aggregated child object). These convenience methods are defined in the langRef. the definition of newChild is below...
best regards -gustaf
Class instproc newChild args { ::set name [[self] autoname -instance [namespace tail [self]]] ::eval [self] create [self callingobject]::$name $args }
As a matter of interest, how many people here only use objects created with autoname?
- ---------- = = ---------//--+ | / Kristoffer Lawson | www.fishpool.fi|.com +-> | setok@fishpool.com | - - --+------ |-- Fishpool Creations Ltd - / | +-------- = - - - = --------- /~setok/
Xotcl mailing list - Xotcl@wi.wu-wien.ac.at http://wi.wu-wien.ac.at/mailman/listinfo/xotcl
On Mon, 28 May 2001, Gustaf Neumann wrote:
Dear Kristoffer,
are you aware of the predefined methods "new" and "newChild" (the first one simplifies only the call to autoname, while the second one creates a new autonamed object as an aggregated child object). These convenience methods are defined in the langRef. the definition of newChild is below...
Yes, I'm aware of them, but they do not do what I mean. I want to create an object as a child of an already existing object which != [self]. "new" creates a new object, but not as an aggregate of another object, "newChild" creates a new object as the child of the calling object. These are very convenient and I use both a lot, but the method I proposed is for easily aggregating a new object to anything.
- ---------- = = ---------//--+ | / Kristoffer Lawson | www.fishpool.fi|.com +-> | setok@fishpool.com | - - --+------ |-- Fishpool Creations Ltd - / | +-------- = - - - = --------- /~setok/
On Monday 28 May 2001 19:02, Kristoffer Lawson wrote:
On Mon, 28 May 2001, Gustaf Neumann wrote:
Dear Kristoffer,
are you aware of the predefined methods "new" and "newChild" (the first one simplifies only the call to autoname, while the second one creates a new autonamed object as an aggregated child object). These convenience methods are defined in the langRef. the definition of newChild is below...
Yes, I'm aware of them, but they do not do what I mean. I want to create an object as a child of an already existing object which != [self]. "new" creates a new object, but not as an aggregate of another object, "newChild" creates a new object as the child of the calling object. These are very convenient and I use both a lot, but the method I proposed is for easily aggregating a new object to anything.
We would propose a new:
Class instproc newChildOf {obj args} { ::set name [[self] autoname -instance [namespace tail [self]]] ::eval [self] create ${obj}::$name $args }
which would be almost identical to newChild, but allows for specifying an object name...
--UZ
On Wed, 30 May 2001, Uwe Zdun wrote:
We would propose a new:
Class instproc newChildOf {obj args} { ::set name [[self] autoname -instance [namespace tail [self]]] ::eval [self] create ${obj}::$name $args }
which would be almost identical to newChild, but allows for specifying an object name...
Yes, that sounds good. If you think that will be the syntax for the next XOTcl release then I'll change what I currently use to do the above.
- ---------- = = ---------//--+ | / Kristoffer Lawson | www.fishpool.fi|.com +-> | setok@fishpool.com | - - --+------ |-- Fishpool Creations Ltd - / | +-------- = - - - = --------- /~setok/
On Wednesday 30 May 2001 16:55, Kristoffer Lawson wrote:
On Wed, 30 May 2001, Uwe Zdun wrote:
We would propose a new:
Class instproc newChildOf {obj args} {
::set name [[self] autoname -instance [namespace tail [self]]] ::eval [self] create ${obj}::$name $args
}
which would be almost identical to newChild, but allows for specifying an object name...
Yes, that sounds good. If you think that will be the syntax for the next XOTcl release then I'll change what I currently use to do the above.
it is already like proposed in the current development version... -gustaf