Re: having a trivial anonymous function call in template prevents compilation?

2016-08-17 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 17 August 2016 at 13:33:26 UTC, Steven 
Schveighoffer wrote:

I think the OP's case is a bug. Please file.


Thanks, I've filed it. Just wanted to get a second opinion before 
concluding that it's a bug.





Re: having a trivial anonymous function call in template prevents compilation?

2016-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn

On 8/17/16 9:23 AM, Lodovico Giaretta wrote:

On Wednesday, 17 August 2016 at 13:21:16 UTC, Cauterite wrote:

On Wednesday, 17 August 2016 at 13:18:06 UTC, Adam D. Ruppe wrote:

Best you can do is use them in an alias argument directly, but you
cannot use them in an enum argument.


I think you missed the point; it works perfectly fine without having
this `({return 0;})()` in the template body (which, as far as I can
see, doesn't appear to interact at all with the template argument).


I think he meant that  ({ return 0;})() cannot be executed at compile
time and assigned to an enum. That's why the instantiation is failing.


Yes, it can: https://dpaste.dzfl.pl/fca15065a4cf

I think the OP's case is a bug. Please file.

-Steve


Re: having a trivial anonymous function call in template prevents compilation?

2016-08-17 Thread Lodovico Giaretta via Digitalmars-d-learn

On Wednesday, 17 August 2016 at 13:21:16 UTC, Cauterite wrote:
On Wednesday, 17 August 2016 at 13:18:06 UTC, Adam D. Ruppe 
wrote:
Best you can do is use them in an alias argument directly, but 
you cannot use them in an enum argument.


I think you missed the point; it works perfectly fine without 
having this `({return 0;})()` in the template body (which, as 
far as I can see, doesn't appear to interact at all with the 
template argument).


I think he meant that  ({ return 0;})() cannot be executed at 
compile time and assigned to an enum. That's why the 
instantiation is failing.


Re: having a trivial anonymous function call in template prevents compilation?

2016-08-17 Thread Cauterite via Digitalmars-d-learn

On Wednesday, 17 August 2016 at 13:18:06 UTC, Adam D. Ruppe wrote:
Best you can do is use them in an alias argument directly, but 
you cannot use them in an enum argument.


I think you missed the point; it works perfectly fine without 
having this `({return 0;})()` in the template body (which, as far 
as I can see, doesn't appear to interact at all with the template 
argument).


Re: having a trivial anonymous function call in template prevents compilation?

2016-08-17 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 17 August 2016 at 13:09:40 UTC, Cauterite wrote:
Just by having a random `({return 0;})()` in the template body, 
suddenly the template rejects its arguments. I'm so confused, 
is this a bug? Or am I missing something?


Function pointers and delegates are not valid compile time 
variables.


Best you can do is use them in an alias argument directly, but 
you cannot use them in an enum argument.


having a trivial anonymous function call in template prevents compilation?

2016-08-17 Thread Cauterite via Digitalmars-d-learn

// -- Example: --

template A(alias Arg) {
enum A = Arg;
	enum Unrelated = ({return 0;})(); // this line prevent 
compilation

};

void main() {
enum FnPtr = &asdf;
enum _ = A!FnPtr;
};

void asdf() {};

// ( https://dpaste.dzfl.pl/79301f12e5fc )

Just by having a random `({return 0;})()` in the template body, 
suddenly the template rejects its arguments. I'm so confused, is 
this a bug? Or am I missing something?