std.digest can't CTFE?

Nick Sabalausky (Abscissa) SeeWebsiteToContactMe at semitwist.com
Fri Jun 1 01:14:18 UTC 2018


On 05/31/2018 06:40 PM, Jonathan M Davis wrote:
> On Thursday, May 31, 2018 14:29:13 Manu via Digitalmars-d wrote:
>> "CTFE
>> Digests do not work in CTFE"
>>
>>
>> That's an unfortunate limitation... why is, those things? :(
> 
> If I had to guess without looking at the code? I would guess that it's doing
> various casts to hash stuff, and no kind of reintpret cast is allowed in
> CTFE. But really, you'd have to actually run the code, see what works and
> what doesn't, and look at each error you get when it doesn't to see what
> it's doing that can't be done during CTFE. Depending on what it's doing, it
> may be possible to make it work during CTFE, or it may not. CTFE can do a
> lot, but there's also a lot that it can't do - especially if you start doing
> anything low level.
> 
> - Jonathan M Davis
> 

I know the SHA1 implementation uses some inline asm. Although, now that 
I think about it, I think that might just be one specialization of the 
implementation, not the only implementation.

Regardless, I do know that std.digest dates back a long time to when 
CTFE was WAY more limited that it is today. Most likely, CTFE at the 
time probably just wasn't quite up to the task, so it was simply left as 
runtime-only. A lot of Phobos was like that back then.

Heck, I wouldn't even be surprised if that note in the docs turned out 
to be outdated and it had magically started working at CTFE at some 
point. But even if not, I'd say it's almost certainly just a classic 
case of "Nobody's needed it badly enough yet to get it working."


More information about the Digitalmars-d mailing list