Re: function is not function

2012-09-26 Thread Don Clugston
On 21/09/12 21:59, Ellery Newcomer wrote: solution is to use std.traits, but can someone explain this to me? import std.stdio; void main() { auto a = { writeln("hi"); }; pragma(msg, typeof(a)); // void function() pragma(msg, is(typeof(a) == delegate)); // nope!

Re: function is not function

2012-09-21 Thread Jonathan M Davis
On Friday, September 21, 2012 12:59:31 Ellery Newcomer wrote: > solution is to use std.traits, but can someone explain this to me? > > import std.stdio; > > void main() { > auto a = { > writeln("hi"); > }; > pragma(msg, typeof(a)); // void function() > pragma(msg, is(typeof(a) == delegate)); // n

Re: function is not function

2012-09-21 Thread Timon Gehr
On 09/21/2012 10:41 PM, Ellery Newcomer wrote: On 09/21/2012 01:17 PM, bearophile wrote: pragma(msg, is(typeof(a) == function)); // nope! code in pyd suggests this evaluated to true once upon a time. I don't think it ever did. It is just very easy to get wrong.

Re: function is not function

2012-09-21 Thread Ellery Newcomer
On 09/21/2012 01:10 PM, Ali Çehreli wrote: You have probably tried the following already: pragma(msg, is(typeof(a) == void function())); No, but that's also not very generic. void main() { auto a = { return 1; }; pragma(msg, is(typeof(a) == void function())); // nop

Re: function is not function

2012-09-21 Thread Ellery Newcomer
On 09/21/2012 01:17 PM, bearophile wrote: pragma(msg, is(typeof(a) == function)); // nope! code in pyd suggests this evaluated to true once upon a time.

Re: function is not function

2012-09-21 Thread bearophile
Ellery Newcomer: pragma(msg, typeof(a)); // void function() Maybe pragma(msg) needs to print function pointer types with a "*", to help remember it's a pointer: int foo1() pure nothrow @safe { return 0; } void main() { static assert(is(typeof(foo1) == function)); auto foo2 = { retur

Re: function is not function

2012-09-21 Thread bearophile
Ellery Newcomer: import std.stdio; void main() { auto a = { writeln("hi"); }; pragma(msg, typeof(a)); // void function() pragma(msg, is(typeof(a) == delegate)); // nope! pragma(msg, is(typeof(a) == function)); // nope! } There is a subtle difference between functio

Re: function is not function

2012-09-21 Thread Ali Çehreli
On 09/21/2012 12:59 PM, Ellery Newcomer wrote: solution is to use std.traits, but can someone explain this to me? import std.stdio; void main() { auto a = { writeln("hi"); }; pragma(msg, typeof(a)); // void function() pragma(msg, is(typeof(a) == delegate)); // nope! pragma(msg, is(typeof(a) ==