explore current scope, or other hack
spir
denis.spir at gmail.com
Mon Nov 15 04:57:29 PST 2010
Hello,
Is there a way to explore the current scope, meaning the set of currently defined symbols?
(Equivalent of python's vars(), locals(), globals().)
I have 2 use cases for this:
1. name objects automatically
I need some objects to know their name (as field on themselves). the only solution I can else imagine is for the user write:
x = ...;
x.name = "x";
I hope you agree this is more than stupid ;-) Exploring the scope would allow providing a tool func that does this automatically, once all objects are known. Is there an alternative I overlook?
2. some tool like format()
Say I wish like to define an alternative approach to variable strings, like
s = VarString("Hello, 'userName'!");
This requires getting variable values at runtime, I guess, meaning explore the scope. How do format and writefln work (pointer welcome)? Is there an alternative?
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
More information about the Digitalmars-d-learn
mailing list