On 28/07/2015 13:28, Cyan Ogilvie wrote:
> I've used a variant on this approach for about 10 years and it's stood> up well in production environments, but something closer to actual value> semantics would be nice. I've thought about implementing a custom> Tcl_Obj type, but that really feels like abuse, and it's tricky to> define a string rep that is efficient.
I've been thinking about doing a garbage-collection scheme for TclOO, to
be only turned on for objects created with the 'new' method. (I suppose
it could even be put in a metaclass, so that existing objects wouldn't
have the problem.) The idea would be to track when there cease to be any
Tcl_Obj references to the object, and delete it when they're gone.
Formally not great — it's not how any “proper” current value semantics
work, though it is close to what JTcl and tcom do — but would work in
practice (and would support the “use as a value” style quite naturally).
Doing it would require some small core changes in the main command
dispatch, as that currently forces values to be of a particular
Tcl_ObjType that doesn't (so far as I know) support useful deletion
callback semantics. Otherwise it would be pretty much self-contained.
Alternatively, TOOT <URL:http://wiki.tcl.tk/11543> by Neil Madden.
Donal.
------------------------------------------------------------------------------
_______________________________________________
Tcl-Core mailing list
Tcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core