Or so I thought. Today I remembered that `pureMalloc` exists, which surely doesn't follow these rules and would definitely not work when memoised. So how come it's still allowed to be `pure` just by resetting ERRNO? It can return a different value with the same input, so does that mean that using RDTSC is also `pure`?
Recently I wanted to write a pure function that returns an
unpredictable number, so I decided to use RDTSC (and any
equivalent instruction for other CPU architectures) to do this,
since the compiler allows RDTSC to be marked as `pure`.
However, in the end I discarded this idea because I figured that
a `pure` function should never return a different value with the
same input; and doing so would surely break any applicable
memoisation. Inline assembly isn't checked by the compiler, so I
was essentially doing the same thing as misusing `@trusted`…
- Is RDTSC pure? IchorDev via Digitalmars-d-learn
- Re: Is RDTSC pure? Kagamin via Digitalmars-d-learn
- Re: Is RDTSC pure? IchorDev via Digitalmars-d-learn
- Re: Is RDTSC pure? Jonathan M Davis via Digitalmars-d-learn
- Re: Is RDTSC pure? IchorDev via Digitalmars-d-learn
