On Wednesday, 18 April 2018 at 10:19:20 UTC, Atila Neves wrote:
On Wednesday, 18 April 2018 at 04:44:23 UTC, Shachar Shemesh
wrote:
On 17/04/18 13:59, Simen Kjærås wrote:
[...]
Also, extremely dangerous.
Seriously, guys and gals. __traits(compiles) (and its uglier
sibling, is(typeof())) sho
On 18.04.2018 09:18, Walter Bright wrote:
On 4/15/2018 10:57 PM, Shachar Shemesh wrote:
It seems that the && evaluation does not stop when the first false is
found.
Evaluation does stop, semantic analysis does not. For example:
bool foo() {
return 0 && undefined_variable;
}
does
On Wednesday, 18 April 2018 at 04:44:23 UTC, Shachar Shemesh
wrote:
On 17/04/18 13:59, Simen Kjærås wrote:
[...]
Also, extremely dangerous.
Seriously, guys and gals. __traits(compiles) (and its uglier
sibling, is(typeof())) should be used *extremely* sparingly.
[...]
A very good rule of
On 4/15/2018 10:57 PM, Shachar Shemesh wrote:
It seems that the && evaluation does not stop when the first false is found.
Evaluation does stop, semantic analysis does not. For example:
bool foo() {
return 0 && undefined_variable;
}
does not compile. I'd speculate that most would con
On 17/04/18 13:59, Simen Kjærås wrote:
There's a kinda neat (and kinda ugly) way to implement prop in one line:
enum prop(T) = __traits(compiles, { static assert(T.member == 3); });
Now, that's not the same as short-circuiting, and only useful in some
cases, but for those cases, it's usef
On Monday, 16 April 2018 at 05:57:01 UTC, Shachar Shemesh wrote:
Consider the following program:
struct S1 {
enum member = 3;
}
struct S2 {
enum member = 2;
}
struct S3 {
}
enum prop(T) = __traits(hasMember, T, "member") && T.member==3;
pragma(msg, prop!S1);
pragma(msg, prop!S2);
pra
On Monday, 16 April 2018 at 05:57:01 UTC, Shachar Shemesh wrote:
Consider the following program:
struct S1 {
enum member = 3;
}
struct S2 {
enum member = 2;
}
struct S3 {
}
enum prop(T) = __traits(hasMember, T, "member") && T.member==3;
pragma(msg, prop!S1);
pragma(msg, prop!S2);
pra
On Monday, 16 April 2018 at 05:57:01 UTC, Shachar Shemesh wrote:
Consider the following program:
struct S1 {
enum member = 3;
}
struct S2 {
enum member = 2;
}
struct S3 {
}
enum prop(T) = __traits(hasMember, T, "member") && T.member==3;
pragma(msg, prop!S1);
pragma(msg, prop!S2);
pra
Consider the following program:
struct S1 {
enum member = 3;
}
struct S2 {
enum member = 2;
}
struct S3 {
}
enum prop(T) = __traits(hasMember, T, "member") && T.member==3;
pragma(msg, prop!S1);
pragma(msg, prop!S2);
pragma(msg, prop!S3);
When compiled, it produces:
true
false
test.d(