Pass symbol to template?

John Colvin john.loughran.colvin at gmail.com
Fri Jul 19 01:40:07 PDT 2013


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.


More information about the Digitalmars-d-learn mailing list