Wanting to persist credentials entered via a dialog. While doing so I wanted to scope them by prepending a type to the symbol name. Came across this behavior which I find odd:
DeleteObject[LocalObjects[]]
f[key_] := Module[{},
If[ValueQ[LocalSymbol[key]],
Print["I have a value for " <> key],
Print["No value for " <> key]
]
]
f[b]
returns: No value for b
The trouble starts if I use a locally defined variable:
g[k_] := Module[{key = k},
If[ValueQ[LocalSymbol[key]],
Print["I have a value for " <> key],
Print["No value for " <> key]
];
]
g["c"]
returns: I have a value for c
key
is still a string in the second definition - any idea why ValueQ[]
thinks it is set?
I can probably manage scoping with a separate directory for each type, but why!?