D safety! New Feature?
Chris Wright via Digitalmars-d
digitalmars-d at puremagic.com
Fri Aug 5 18:38:57 PDT 2016
On Fri, 05 Aug 2016 23:12:06 +0200, ag0aep6g wrote:
> On 08/05/2016 09:39 PM, Mark J Twain wrote:
>> In the case of ImmutableQueue, There is no Enqueue!
>>
>> See, there is a difference between "not callable" and "does not
>> exists".
>
> Ok, but what cool stuff is enabled by "does not exist" that doesn't work
> (as nicely) with "not callable"? As far as I can tell, there is no
> difference in practice.
Some reflection stuff is a bit inconvenient:
class A {
int foo() { return 1; }
}
void main() {
auto a = new immutable(A);
// This passes:
static assert(is(typeof(a.foo)));
// This doesn't:
static assert(__traits(compiles, () { a.foo; }));
}
__traits(compiles) is mostly an evil hack, but things like this require
its use.
More information about the Digitalmars-d
mailing list