If you could make any changes to D, what would they look like?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Sat Oct 30 10:25:35 UTC 2021


On Friday, 29 October 2021 at 21:56:10 UTC, Adam Ruppe wrote:
> On Friday, 29 October 2021 at 21:16:49 UTC, H. S. Teoh wrote:
>> Long story short, pureFree makes no sense
>
> What about:
>
> void foo() pure {
>    int* a = malloc(5);
>    scope(exit) free(a);
> }
>
>
> How is that any different than
>
> void foo() pure {
>    int[5] a;
> }
>
> ?


That depends on how malloc and free are implemented... Should you 
for instance be allowed to do locking in a pure function? 
Probably not. You cannot call such code in a real time thread. If 
you cannot call a pure function in a real time thread then I 
think the advantage is completely lost for system level 
programming.

The problem here is having a good definition for pure.



More information about the Digitalmars-d mailing list