Vladimir Panteleev wrote:
I believe that's what __traits(compiles, ...) is for:
__traits(compiles, cast(T) o) is true even if the cast blows up in CTFE, so
that doesn't work.
On 12/21/2011 09:15 PM, Elvis Maehren wrote:
This works fine at runtime, but explodes in CTFE:
---
bool isInstanceOf(T, O)(O o) {
return (cast(T) o) !is null;
}
---
CTFE doesn't like !is null (cannot compare [...] at compile time).
This will be fixed in the next release:
I'd really like to have 'if (instance is ClassType)' syntax in D.
On Thu, Dec 22, 2011 at 8:35 AM, Trass3r u...@known.com wrote:
I'd really like to have 'if (instance is ClassType)' syntax in D.
It couldn't use that syntax because 'is' means direct bitwise equality
everywhere else. Changing it in this one situation would be awkward.
This works fine at runtime, but explodes in CTFE:
---
bool isInstanceOf(T, O)(O o) {
return (cast(T) o) !is null;
}
---
CTFE doesn't like !is null (cannot compare [...] at compile time).
Moreover, in CTFE a failed cast terminates the interpretation (cannot
reinterpret class from [...]
On Wednesday, 21 December 2011 at 20:15:36 UTC, Elvis Maehren
wrote:
Is this somehow catchable?
I believe that's what __traits(compiles, ...) is for:
http://dlang.org/traits.html#compiles
On 2011-12-21 21:15, Elvis Maehren wrote:
This works fine at runtime, but explodes in CTFE:
---
bool isInstanceOf(T, O)(O o) {
return (cast(T) o) !is null;
}
---
CTFE doesn't like !is null (cannot compare [...] at compile time).
Moreover, in CTFE a failed cast terminates the