How can I put the current value of a variable into a delegate?
Liam McGillivray
yoshi.pit.link.mario at gmail.com
Thu May 9 00:06:34 UTC 2024
On Wednesday, 8 May 2024 at 12:29:05 UTC, Rene Zwanenburg wrote:
> Interestingly enough C# used to have the same behaviour but MS
> decided to go for a breaking change in C# 5; now it behaves as
> most people expect.
Wow! I wonder if D would be willing to allow such a breaking
change with the release of Phobos 3. My choice would be to have
it use the current value by default for value types, but allow
them to be linked to the same memory address using `*&` when the
variable is placed in a delegate. I think that the distinction
between value types and reference types should be consistent.
If such a breaking change isn't considered acceptable, I suppose
a new operator can be introduced for dereferencing a variable
when placed in a delegate. Maybe `#` or `$` if they don't
conflict with any existing use of those symbols.
More information about the Digitalmars-d-learn
mailing list