[Xotcl] constant/immutable property
Gustaf Neumann
neumann at wu-wien.ac.at
Wed Jan 4 11:00:56 CET 2012
Dear Victor,
While it is easy to provide a slim implementation, which
works nicely for particular cases, it is much more
complicated to provide a general solution that works for all
potential use cases.
Here are a few questions one has to address here:
* Most likely, one would expect something like a write-once
semantic via the property (declare the property, assign
later some value to it, etc.) rather than a true "const" (at
least when "property" rather than "variable" is used).
* Since Tcl variables can be altered in many ways (output
variables of cmds, resolver, ...) a true "const" must be
most likely realized via traces (which have often tricky
issues).
* it is not clear, whether "const" should imply different
write semantics, or as well different unset semantics. In
the latter case, when a destroy happens, one should
certainly unset the variables even when they are "const".
Also, copy/move operations tend to be tricky.
* when const is a slot property, we should address as well
cases for slots with additional semantics (such as
persistent, database-mapped slots, etc.)
Actually, my goal would even go further, by setting
optionally objects/classes immutable, but this is opening
some more cans of worms, but this opens as well some more
potential optimizations.
With have the "immutable" theme block on our todo list, but
not for the initial release.
-gustaf neumann
On 03.01.12 20:47, Victor Mayevski wrote:
> Thank you Gustaf and Sefan,
>
> Would it be possible to add that functionality into NX core? For example, via:
>
> Obj property {key:constant value}
> Obj variable key:constant value
>
> I know I can code it myself but I think programmers would prefer for
> it to be a built-in function.
More information about the Xotcl
mailing list