std.traits.ParameterIdentifierTuple problem

Carl Sturtivant sturtivant at gmail.com
Sat Mar 30 23:35:09 UTC 2024


On Saturday, 30 March 2024 at 22:37:53 UTC, Carl Sturtivant wrote:
> Incidentally, I tried
> ```D
> extern typeof(foo) func;
> ```
> to say that func was an actual function (`extern` so defined 
> elsewhere) whose type was the type of the function `int foo(int 
> num, string name, int);` so I can then use 
> `ParameterIdentifierTuple` on a function, not a type, but the 
> compiler said `bug1.d(5): Error: variable ``bug1.func`` cannot 
> be declared to be a function`. Seems unreasonable given the 
> implied semantics.

The word *variable* in that error message caught my eye and it 
struck me that in some sense a function is a constant, not a 
variable, we have function pointers for the last. So I tried
```D
enum typeof(foo) func = void;
```
to see if I could escape this difficulty. Sadly got exactly the 
same error message, even though no variable was involved.


More information about the Digitalmars-d-learn mailing list