Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
May 31, 2018 Re: std.digest can't CTFE? | ||||
---|---|---|---|---|
| ||||
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
|
May 31, 2018 Re: std.digest can't CTFE? | ||||
---|---|---|---|---|
| ||||
Hashing's not low-level. It would be great if these did CTFE; generating compile-time hashes is a thing that would be really useful! Right here, I have a string class that carries a hash around with it for comparison reasons. Such string literals would prefer to have CT hashes.
On 31 May 2018 at 15:40, Jonathan M Davis via Digitalmars-d <digitalmars-d@puremagic.com> 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
>
|
May 31, 2018 Re: std.digest can't CTFE? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | 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."
|
May 31, 2018 Re: std.digest can't CTFE? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky (Abscissa) | On 31 May 2018 at 18:14, Nick Sabalausky (Abscissa) via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> 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."
It doesn't work. I suspect a blunt pointer cast where a shift&mask could be is the culprit.
The demo effect always seems to plague D every time I try and introduce new people >_<
|
May 31, 2018 Re: std.digest can't CTFE? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky (Abscissa) | On Thursday, May 31, 2018 21:14:18 Nick Sabalausky via Digitalmars-d wrote:
> 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."
Yeah, unless there's something about the implementation that actually requires something low level that can't be done during CTFE, or it requires a C function, then it's almost certainly just a matter of someone taking the time to make it work during CTFE (even if that involves using __ctfe). Presumably, either no one has had enough of a need to make it work, or the few who did didn't want to go to the effort of making it work. I have no idea how much the need to use std.digest at compile-time actually comes up. I would have thought that in most cases, you'd be hashing a file or something else that's read at runtime, but I don't know. Personally, I think that I've used std.digest all of once.
- Jonathan M Davis
|
Copyright © 1999-2021 by the D Language Foundation