Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-05-23
14:09 • Ticket [2006660fff] constructorinit status still Open with 7 other changes artifact: b0fe311b29 user: dkf
2009-05-11
21:00 • Ticket [2006660fff]: 1 change artifact: 425beb1459 user: dkf
2008-06-30
11:17 • New ticket [2006660fff]. artifact: 0cfc743bc0 user: wiede

constructorinit

Open2006660fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 3 years ago
Descriptionplain2008-06-30 11:17:31
itcl has a special feature called constructor init code which is like a body of a proc/script and which is called  directly before the constructor is called with the same callFrame and arguments as the constructor. That is used for example to call constructors explicitly before the normal construction mechanism is doing the calls.

to allow itcl to handle that, here the proposed change to TclOO:

add a ::oo::define constructorinit command on the scripting level.

Add a Tcl_SetConstructorInit command at the C-API and add a constructorInitPtr to the class structure (+ additional stuff in the Foundation, the same as for constructor).

Add additional code in TclOOCall.c on places where CONSTRUCTOR is handled to add a call to the constructorInit code (if it exists) just before the call to the constructor code.
dkf Ticket [2006660fff]: 1 change [History diff]2009-05-11 21:00:38
dkfmarkdown2024-05-23 14:09:02

Does the object instance exist at that point or not?

If this is prior to the object existing, it's best done by enhancing the create and new methods in an oo::class subclass.

If the instance exists, then it's the job of the constructor to set things up. I guess in that case we'd be looking at a "filter for constructors"? I'm not sure how that would work. (For balance, a "filter for destructors" would also be possible, though that would need to be careful as they're called at tricky times such as when the containing namespace is deleted or the interpreter is killed.) This is all just guessing, of course.

I don't want to add a lot of mandatory overhead into the instance creation path (or the general cached method call path either).

Log in (anonymous is fine) to add a comment.