[Xotcl] Incorrect behavior?

Stefan Sobernig stefan.sobernig at wu.ac.at
Wed Jun 29 12:32:04 CEST 2011


> %Object create o
> ::o
> %o attribute {a oldvalue}
> ::o::a
> %o a
> oldvalue
> %o attribute {a newvalue}
> ::o::a
> %o a
> oldvalue

Incorrect behavior? Not quite, but probably behaviour not that 
"accessible" at first sight :)

In line 5, by accessing a, the default value "oldvalue" is assigned to 
am object variable a owned by ::o. In line 7, by providing a new default 
value, you do not change the state of ::o (the value assignment of the 
var a), rather you modify a property of the attribute slot a.

So, in line 9, given that an object variable a already exists, the slot 
machinery does not (re-)assign the default value. You would have to 
clear ::o's state first:

::o eval {unset :a}

and then do:

o attribute {a newvalue}
o a

Note that currently, for per-object attributes only, the unset *must* 
happen before the re-definition of the attribute slot and its default. 
There might be ways to relax this restriction at some point ...


More information about the Xotcl mailing list