Overview
| Artifact ID: | b0fe311b2954562a0a2fe5be5cab4482380d3c046664b3021c6cfcf5de21c738 |
|---|---|
| Ticket: | 2006660fffffffffffffffffffffffffffffffff
constructorinit |
| User & Date: | dkf on 2024-05-23 14:09:02 |
Changes
- closer changed to: "nobody"
- comment changed to:
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.
- icomment:
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).
- login: "dkf"
- mimetype: "text/x-markdown"
- severity changed to: "Minor"
- title changed to: "constructorinit"