digitalmars.D.learn - String pasting / symbol construction?
- Bill Baxter (17/17) Jan 26 2007 Just checking ... there's still no way to construct symbols (maybe
Just checking ... there's still no way to construct symbols (maybe tokens is the right word?) at compile time is there? For instance if I want to have something like template funcs(char[] suffix) { } resulting in funcs!("f").function1() being equivalent to the call function1f() There's still no way to do that, right? Any good workarounds? (In this case I'd actually like to take 3 strings and paste em together like that to make a function name). --bb
Jan 26 2007
Bill Baxter wrote:There's still no way to do that, right? Any good workarounds?Nope. But if someone is counting votes, I'd like that functionality as well.
Jan 27 2007
Reply to Bill,Just checking ... there's still no way to construct symbols (maybe tokens is the right word?) at compile time is there? For instance if I want to have something like template funcs(char[] suffix) { } resulting in funcs!("f").function1() being equivalent to the call function1f() There's still no way to do that, right? Any good workarounds? (In this case I'd actually like to take 3 strings and paste em together like that to make a function name). --bbnot directly but checkout my dparse lib (dource -> projects -> scrapple -> dparse) it uses template specializations to generate and refer to custom symbol names. It's limited (no forward reference and everything must be declared in the same scope) but I works for the most part. Allowing template specializations to overload from different scopes and allowing lazy lookup or forward referencing of specializations* would make this vary powerful. * IIRC these aren't in the spec but DMD seems to handle them some way
Jan 27 2007