| Store | Cart

Re: [TCLCORE] Tcl Objects with value semantics

From: Donal K. Fellows <dona...@manchester.ac.uk>
Tue, 28 Jul 2015 15:07:30 +0100
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
Recent Messages in this Thread
Duquette, William H (393K) Jul 27, 2015 07:56 pm
Peter S Jul 28, 2015 12:07 pm
Duquette, William H (393K) Jul 28, 2015 03:23 pm
Cyan Ogilvie Jul 28, 2015 12:28 pm
Donal K. Fellows Jul 28, 2015 02:07 pm
Duquette, William H (393K) Jul 28, 2015 08:15 pm
Messages in this thread