I would like to simplify some database notation, and I'm doing some tests with UpValues
for that.
For example, if I set this Upvalue fot tab1:
tab1 /: tab1.column1 = 1
When I evaluate
tab1.column1
I get 1
as expected. But if later I set column1 = "x"
, when I evaluate it again, I get tab1."x"
instead of 1
as I need.
There is some way that I can change this behavior? So I could get 1
and prevent variables name conflict?
Update
To avoid misinterpretation here is the evaluation sequence.
Quit the kernel and evaluate:
tab1 /: tab1.column1 = 1;
column1 = "x";
tab1.column1
The result is tab1."x"
in the first evaluation.
1
, as expected, in version 9.0.0 (Windows Vista). $\endgroup$tab1."x"
for all evaluations oftab1.column1
. That's what I would expect because I think the ownvalue forcolumn1
is in inserted intoDot
beforetab1
is checked for upvalues. $\endgroup$Unprotect@Dot; SetAttributes[Dot, HoldAll]
it will works as I need, but now I'm looking for some way to do that without useUnprotect@Dot
(I don't know if it's possible). Another test istab1.Unevaluated@column1
. Tks. $\endgroup$Internal
InheritedBlock` $\endgroup$