Pure functions in D

BCS ao at pathlink.com
Mon Sep 29 16:19:31 PDT 2008


Reply to bearophile,

> BCS:
> 
>> To forbid such a cast, you would need to forbid pointers to pure
>> functions. You can subvert the type system with unions if nothing
>> else and for something like pure, there is no point in limiting casts
>> if there are ways around it.
>> 
> If it turns out that casting impure => pure is very dangerous (and I
> don't know yet how much dangerous it can be), then it may be useful
> anyway to forbid the simple impure => pure cast, forcing the
> programmers to perform that cast with a union. So it becomes a way to
> tell the programmer that operation is very discouraged :-)
> 
> Bye,
> bearophile

If the correct way is to use a cast, you can grep for it, if you need to 
use a union, it will be extremely hard to find such casts. Thus the reason 
to allow the cast or make it totally impossible.





More information about the Digitalmars-d mailing list