Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-05-13
02:17 • Ticket [1959486fff] :define and self.* status still Closed with 4 other... artifact: 50e9f0ac8e user: dgp
2008-05-11
17:11 • Ticket [1959486fff]: 4 changes artifact: 0b24967420 user: dkf
2008-05-09
07:28 • Ticket [1959486fff]: 4 changes artifact: 3b1b531437 user: das
06:09 • Closed ticket [1959486fff]. artifact: 1f4b73a2ac user: dkf
04:49 • Ticket [1959486fff]: 4 changes artifact: 1655329bb9 user: kennykb
2008-05-08
22:31 • Ticket [1959486fff]: 4 changes artifact: ee3ff8b5ce user: dkf
22:20 • Ticket [1959486fff]: 1 change artifact: 9626ff36eb user: dkf
22:20 • Ticket [1959486fff]: 4 changes artifact: 9290f47cfa user: dkf
2008-05-07
12:49 • New ticket [1959486fff]. artifact: cd1ab4b0e4 user: dgp

[oo::define] and self.*

Closed / Accepted1959486fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-05-07 12:49:51
Please address the comments in

http://aspn.activestate.com/ASPN/Mail/Message/tcl-core/3316529

Too low on network connect and power
to rephrase again here at the moment.
dkfplain2008-05-08 22:20:25
Logged In: YES 
user_id=79902
Originator: NO

From the link...

My reaction re-reading the TIP is that this complexity appears to be the 
result of forcing everything into a single command, [oo::define]:

   oo::define $objectOrClass $script

The commands in $script do different things depending on whether or not 
$objectOrClass is a class, and then there are special self.* provisions 
to force a class value of $objectOrClass to be treated as a plain object 
value of $objectOrClass.  (Since every class is also an object).

Seems to my uneducated perspective it would be clearer to have two 
defining commands:

   oo::objdef $object $script1

   oo::classdef $class $script2

And have the commands in $script1 treat $object as an object and the 
commands in $script2 treat $class as a class (and oo::classdef error in 
the case that $class is not a class).

It's not like anyone can use the proposed [oo::define] effectively 
without knowing whether or not the first argument they pass is a class 
or not.  So if they have that knowledge, there's no additional burden in 
having them choose between [objdef] and [classdef].  I think?

I'm guessing there's some deep reason either in the theory or in the 
implementation why things haven't gone that way, and I don't yet 
appreciate it, but that's my reaction trying to navigate the 
[oo::define] spec.
dkf Ticket [1959486fff]: 1 change [History diff]2008-05-08 22:20:46
dkfplain2008-05-08 22:31:52
Logged In: YES 
user_id=79902
Originator: NO

My response...

That's a really good suggestion actually. I might go for oo::objdefine instead of oo::objdef and leave oo::define for classes, but the overhead's quite low either way.

Now, why don't I remember seeing this before? :-(
kennykbplain2008-05-09 04:49:45
Logged In: YES 
user_id=99768
Originator: NO

I like oo::objdef and oo::define.  oo::define is the usual thing to
do in a class-based (rather than traits-based) system, so it makes
sense to have it be the one with the unqualified name.

And it gets rid of the self.* stuff.

If we can do it quickly, make it so!
dkfplain2008-05-09 06:09:05
Logged In: YES 
user_id=79902
Originator: NO

Implemented it! Will form part of 0.3.

(I'm glad really, the self. prefixes had been bothering me for a while, but when we did the initial design they were the best idea we could come up with. But splitting oo::define really is much better.)
dasplain2008-05-09 07:28:18
Logged In: YES 
user_id=90580
Originator: NO

one disadvantage of this solution is that you now can no longer use the self. commands in a oo::class create {} block e.g. to define a class method, you have to use a separate oo::objdef now, splitting the class definition among several commands...
Worth it to get rid of the self. ugliness IMO, but if possible it might be nice to have a way to somehow integrate the objdef bits of a class definition into the oo::class block, e.g. with a self {} subblock or something of that nature ?
dkfplain2008-05-11 17:11:27
Logged In: YES 
user_id=79902
Originator: NO

That's another good suggestion. Implemented.
dgpplain2008-05-13 02:17:37
Logged In: YES 
user_id=80530
Originator: YES


Thanks for considering and acting on this.
I'm ok with what you've done.

FWIW, reading my own message 18 months later,
today I think I would suggest an "ensemble"
solution:

  oo::define object $object $script1
  oo::define class $class $script2

Make of that what you will.
Log in (anonymous is fine) to add a comment.