Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

string to identifier?

Name: Anonymous 2010-04-20 9:03

There is something I have been wondering for a while and never found the answer to.
Is there any way in c++ to convert a string or maybe a stringstream to a variable identifier?

Name: Anonymous 2010-04-20 9:11

http://lmgtfy.com/?q=C%2B%2B+reflection

But why would you even want this? When no serious CPP projects done without strong use of ASM, why would one wish for things which are SLOW AS FUCK by definition?

Name: Anonymous 2010-04-20 9:16

>>2
Enable javascript to use LMGTFY.

Name: Anonymous 2010-04-20 9:18

randomizing variable names. I guess I won't bother

Name: Anonymous 2010-04-20 9:19

>>3
No pain, no gain.

Name: Anonymous 2010-04-20 9:28

You can in Lisp, but only for globals. Lexicals are compiled in most sane languages, thus they don't exist past compilation stage. Of course, it would be possible to store the location of all local variables and use that for lookup purposes, but you'd be wasting a lot of memory and adding a lot of unneeded overhead to achieve this. One of the simplest way to achieve what you wanted would be to make a hashtable keyed by identifier strings, and use that for all your global variables. If you language supported symbol macros, you could even make them appear as actual globals, and if you had some sort of real macro support, you could even cache the locations for speed (if a literal symbol is found, the lookup can be done at compile time). Lisp supports this natively, though if it didn't, you could implement it yourself. I don't know if SEPPLES can do this, but it surely can do at least a simple hashtable keyed on strings.

Name: Anonymous 2010-11-26 1:16

Name: Anonymous 2010-12-21 5:11

Name: Anonymous 2011-02-04 18:38

Name: Anonymous 2011-02-18 12:59

that's cool and all, but check 'em
Don't change these.
Name: Email:
Entire Thread Thread List