toHash => pure, nothrow, const, @safe

Timon Gehr timon.gehr at gmx.ch
Mon Mar 12 13:57:28 PDT 2012


On 03/12/2012 09:46 PM, Jonathan M Davis wrote:
> On Monday, March 12, 2012 21:36:21 Martin Nowak wrote:
>>> That could be solved with a @ctfe attribute or something, no? Like, if
>>> the function has @ctfe, go through all possible CTFE paths (excluding
>>> !__ctfe paths of course) and make sure they are CTFEable.
>>
>> Everything that's pure should be CTFEable which doesn't imply that you
>> can turn every CTFEable function into a pure one.
>
> I don't think that that's quite true. pure doesn't imply @safe, so you could
> do pointer arithmetic and stuff and the like - which I'm pretty sure CTFE won't
> allow. And, of course, if you mark a C function as pure or subvert pure
> through casts, then pure _definitely_ doesn't imply CTFEability.
>
> - Jonathan M Davis

CTFE allows quite some pointer arithmetic, but makes sure it is actually 
safe.


More information about the Digitalmars-d mailing list