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!
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
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.
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
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.
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
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
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) ==