D isn't the only language with janky closure semantics
H. S. Teoh
hsteoh at qfbox.info
Sun Aug 31 14:39:02 UTC 2025
On Sat, Aug 30, 2025 at 09:45:33PM +0000, monkyyy via Digitalmars-d wrote:
> On Saturday, 30 August 2025 at 21:10:59 UTC, H. S. Teoh wrote:
[...]
> > Whether or not it's a #wontfix, I'm gonna keep complaining until it
> > gets fixed. ;-)
> >
> > The current behaviour is pretty much completely useless 100% of the
> > time, so in keeping with D's philosophy of catering to the most
> > common use cases, this should be fixed. It doesn't make sense that
> > we have to work around this every single time, when it doesn't even
> > serve a single useful use case.
[...]
> Agreed, but Ive read the old bug reports to verify as of 2022 walter
> thought "allocating bad >:(" given that I believe that any useful
> behavior is allocating the arguments as tuples this is on my list of
> explicit #wontfixes
[...]
The thing is, we *already* allocate when the delegate closes over local
variables. Otherwise delegates would crash almost everywhere.
The only thing needed was to detect closures over the loop variable, and
include it in the allocated context. It's not a completely foreign
concept to how D already works.
T
--
Gone Chopin. Bach in a minuet.
More information about the Digitalmars-d
mailing list