| |
|
Elronnd
Posted in reply to Stanislav Blinov
| On Sunday, 14 November 2021 at 02:54:52 UTC, Stanislav Blinov wrote:
> On Sunday, 14 November 2021 at 02:24:42 UTC, Elronnd wrote:
>
>> A signal handler may not be pure, and it may be called at any time. Including during the execution of a pure function. Hence, your argument implies that no function should ever be marked as pure, because it may be interrupted by a signal handler which has some effects.
>
> Yes, yes, and cosmic radiation may flip a bit in my CPU thus also mutate my state. I still don't see what that has to do with the language and its runtime.
Signals are part of the language. Proof: GC must be able to hijack threads; so there must be some mechanism for preempting an existing thread of execution; and GC is part of the language.
Hence, that a function is 'pure' cannot be a strict indicator that, between the time it is called and the time it returns, no side effects are performed.
So it seems not at all inconsistent to me that a pure function may cause the GC to run, causing a destructor to be run.
|