View · Search · Index
No registered users in community xowiki
in last 10 minutes

[Xotcl] Re: aggregate objects with autoname

From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Mon, 28 May 2001 12:18:45 +0200

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_at_fishpool.com | - - --+------
>
> |-- Fishpool Creations Ltd - / |
>
> +-------- = - - - = --------- /~setok/
>
>
> _______________________________________________
> Xotcl mailing list - Xotcl_at_wi.wu-wien.ac.at
> http://wi.wu-wien.ac.at/mailman/listinfo/xotcl