|
From: Will D. <wi...@wj...> - 2005-09-29 02:17:15
|
Donal,
On Sep 28, 2005, at 2:19 AM, Donal K. Fellows wrote:
> Will Duquette wrote:
>> On Sep 27, 2005, at 1:17 AM, Donal K. Fellows wrote:
>
>> Also, the "unknown" method is in some sense a magic method; it
>> reminds me of Python's magic methods that implement things like
>> dictionary look-ups. They have names like __methodname__, beginning
>> and ending with a couple of underscores. I wonder if we want to
>> adopt a naming convention like that for magic methods like "unknown"
>> that you will often define but will rarely call explicitly.
>>
>
> The most traditionally magic thing in Tcl is the global [unknown]
> command and that has magic enough for a whole legion of OO
> systems. :-)
> But yes, I'm happy to negotiate on this sort of thing.
If we don't have any other "magic" methods it probably isn't
necessary; but if we define all methods whose names begin with
an underscore (or two underscores) as reserved, we can add magic
methods in the future with less worry about collisions.
>> Also, another point--you can get an automatically generated name,
>> but with this mechanism you can specify part of the name. In
>> Snit, for example, you can create a snit::widget like this:
>> mywidget $parent.%AUTO%
>> I don't see any way to do this with your mechanism and still
>> guarantee uniqueness, unless I check for uniqueness myself.
>>
>
> Frankly, I'd just use a global sequence number. Cheap and works nearly
> all the time. :-) Any time that's inadequate, I'd probably be best off
> doing it myself through a subclass of class. (And no, I'm not keen on
> magic substitutions; they force parsing of the name and you have to
> document them carefully.)
I'd be happy to use a global sequence number in application code;
but when a user asks Snit to create a unique name I want a name
that's guaranteed to be unique, not just probably unique.
Will
-------------------------------------------------------------
will -at- wjduquette.com | Catch our weblog,
http://foothills.wjduquette.com | The View from the Foothills
|