Bug 23633 – allow pure functions to call impure functions passed as parameters

Status
NEW
Severity
enhancement
Priority
P5
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-01-16T01:29:10Z
Last change time
2024-12-13T19:26:43Z
Assigned to
No Owner
Creator
Adam D. Ruppe
Moved to GitHub: dmd#18147 →

Comments

Comment #0 by destructionator — 2023-01-16T01:29:10Z
Basically, permit this: ``` void foo(void delegate() dg) pure { dg(); } ``` Similarly to how you can write to values passed through params, if an impure delegate is passed through params I think we can allow that as an extension of the weakly pure concept. This would allow things like passing properties to be set. If you are passed a class/interface tho, probably should only allow the pure members since that's not as explicit as the delegates. I often find myself wanting some kind of limited environment to a function, and pure ALMOST offers it, but it just isn't able to do enough since pure is too strict, this kid of relaxation just might make it work.
Comment #1 by robert.schadek — 2024-12-13T19:26:43Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18147 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB