Pass symbol to template?
JS
js.mdnq at gmail.com
Fri Jul 19 02:00:40 PDT 2013
On Friday, 19 July 2013 at 08:40:09 UTC, John Colvin wrote:
> On Friday, 19 July 2013 at 08:08:25 UTC, JS wrote:
>> I have some templates to help initialize things, like a
>> property getter and setter.
>>
>> mixin(Property!("Name", int));
>>
>> creates a property named Name with type int.
>>
>> I'd like to be able to call it like
>>
>> mixin(Property!(Name, int));
>>
>> (Name is a symbol but undefined at the mixin site(since it
>> will be defined once the mixin is done)
>>
>> I doubt this is possible in any way because it requires the
>> compiler to allow such undefined symbols but would be nice...
>>
>> e.g.,
>>
>> template Property(lazy alias name, type) { ... }
>>
>> but who knows, maybe I'm wrong and there is some way to do
>> this?
>
> There isn't a way AFAIK
>
> You can use the q{...} syntax though, which is particularly
> nice for passing large code strings.
I'm just passing short string literals to represent variable
names... It's not a huge deal but I wanted to avoid the quotes if
I could(since they serve no real purpose).
More information about the Digitalmars-d-learn
mailing list