Order of evaluation for named arguments
Dukc
ajieskola at gmail.com
Sat Apr 5 20:18:28 UTC 2025
On Saturday, 29 March 2025 at 18:38:31 UTC, Steven Schveighoffer
wrote:
> So the question is, should we modify the spec to reflect this,
> or would it be better to change the compiler to enforce this
> left-to-right evaluation rule?
Dennis's point that the language already evaluates right-to-left
in some cases is good. Also that the spec note about evaluation
order essentially means only unnamed arguments since it was
written when named args didn't exist. So we could just as well
keep the behaviour as is.
However, I don't think changing the behaviour is wrong either.
Anyone who was relying on this certainly knew or should have
known that s/he is on thin ice. Of course it's unfortunate that
we end accidentally end up using implementation-defined features
every now and then, but the language can't improve if we let that
stop us from changing it. Especially in this case, since it's an
young feature that is unlikely to be used that much yet.
So I guess it is up to taste. My personal preference is left to
right at the call site. If we're that afraid of breakage the
change can wait for the next edition but it doesn't seem
necessary to me.
More information about the Digitalmars-d
mailing list