Re: How to fake pure

2025-04-08 Thread Dom DiSc via Digitalmars-d-learn
On Tuesday, 8 April 2025 at 15:54:52 UTC, Timon Gehr wrote: In any case, casting a memory allocator to `pure` should be fine. Any reasonable definition of `pure` we can come up with in the future would be compatible with that. Yes, this is also what I think. Of course an allocator cannot be s

Re: How to fake pure

2025-04-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 8, 2025 9:07:45 AM MDT Guillaume Piolat via Digitalmars-d-learn wrote: > On Tuesday, 8 April 2025 at 14:00:56 UTC, Jonathan M Davis wrote: > > Of course, I'm also increasingly of the opinion that pure was a > > mistake in general, because it does almost nothing in practice > > bu

Re: How to fake pure

2025-04-08 Thread Timon Gehr via Digitalmars-d-learn
On 4/8/25 17:07, Guillaume Piolat wrote: On Tuesday, 8 April 2025 at 14:00:56 UTC, Jonathan M Davis wrote: Of course, I'm also increasingly of the opinion that pure was a mistake in general, because it does almost nothing in practice but routinely doesn't work with straightforward code - and it

Re: How to fake pure

2025-04-08 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 8 April 2025 at 14:00:56 UTC, Jonathan M Davis wrote: Of course, I'm also increasingly of the opinion that pure was a mistake in general, because it does almost nothing in practice but routinely doesn't work with straightforward code - and it's definitely one of those attributes whi

Re: How to fake pure

2025-04-08 Thread Dom DiSc via Digitalmars-d-learn
On Tuesday, 8 April 2025 at 14:00:56 UTC, Jonathan M Davis wrote: You basically have to lie to the compiler and cast the function pointer to pure [...]. That being said, core.memory has pureMalloc and pureFree which do that for you already, including mucking around with errno to ensure that

Re: How to fake pure

2025-04-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 8, 2025 5:28:57 AM MDT Dom DiSc via Digitalmars-d-learn wrote: > Hi. > > I want to create my own allocator, but using malloc is not pure > (it internally has to have some "global state"). But the GC also > has this "global state" and still is considered "pure". > So internally the

How to fake pure

2025-04-08 Thread Dom DiSc via Digitalmars-d-learn
Hi. I want to create my own allocator, but using malloc is not pure (it internally has to have some "global state"). But the GC also has this "global state" and still is considered "pure". So internally the impurity of the allocators has been hidden. How can I do this? adding @trusted doesn't