On Friday, 8 May 2015 at 12:44:31 UTC, Artur Skawina wrote:
On 05/08/15 03:53, Brian Schott via Digitalmars-d-learn wrote:
The problem occurs when I want to register multiple modules to scan for functions. The grammar does not allow this syntax:

```
template (alias Modules ...) {
...
```

The grammar allows omitting the 'alias' keyword.

artur

alias parameters are different from normal template parameters. They're not necessary for this problem, but they are for others.

As an example:


void traceVar(alias var, size_t line = __LINE__, string file = __FILE__)()
{
        import std.stdio: stderr;
        stderr.writeln(file, "(", line, ") ", var.stringof, ": ", var);
}

This allows you to print a variable's name and value by only passing the variable once as a template argument. Allowing "template Tem(alias Args ...)" syntax would let me trace multiple variables at once.

If you omit "alias", "var.stringof" evaluates to "var" instead of its name in the calling context.

Reply via email to