-
-
Notifications
You must be signed in to change notification settings - Fork 380
Evaluation order of function arguments #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
According to TDPL p. 50 (section 2.3.5.3 Function Call) function arguments are evaluated left to right. This commit fixes the examples in the documentation where it is assumed that the evaluation order is unspecified.
Let's leave this on the back burner until the front end actually implements consistent LTR evaluation. |
Fine with me. I just wanted to write this to make sure it won't be forgotten. |
What's the state of this? |
Not implemented yet as far as I know, |
Assigning this to Walter. FWIW Walter and I agree this needs done but Walter didn't have the time. So @9rsr and @dawgfoto you may want to work on this if it catches your fancy, it's a sure hit. |
Let us merge this please. The current state of affairs is that the implementation is wrong, but this documentation is right. @dawgfoto already posted links to the relevant bugs, so I see no reason to not merge this now so other compilers than DMD can implement the defined order. |
How would pushing the documentation help the implementation? We've had requests to amend the documentation the other way around. |
The problem is that we're treating the documentation as if it's implementation documentation. It's not. D has no formal specification, so there's no other place to put this kind of stuff. Clearly, LTR evaluation is a language requirement, but since it isn't spec'd anywhere, compiler implementors are not implementing it and it'll remain implementation-defined. @ibuclaw has said that he'll implement LTR evaluation as soon as it's actually spec'd properly, for instance. |
It also changes the LTR ordering from an enhancement request to a compiler bug. It's in some ways semantics (sorry, couldn't resist the pun), but it's also a language design process issue. If we wait for DMD to implement a language change, that bottlenecks language design issues in an odd place. |
Imho, there is only one sane option: Document the intended behavior, while at the same time mentioning that it is currently not implemented in DMD (since DMD is our reference frontend, users might be confused if we don't) – the docs are our specs, and how is this ever going to be implemented »correctly« in compilers (excluding DMD) if it isn't even specified behavior? @dawgfoto: I'd not say By the way, having a language with inline assembly but a totally underspecified calling convention is certainly one of the more annoying thing if you are working on an alternative implementation… |
@andralex Waiting for DMD to implement things is IMO, one of the reasons D have such a poor tooling. The spec is so tied to DMD that this make the task almost impossible. BTW, I spend today quite a lot of time today debuging someting like foo() ~ bar; where foo have side effect on bar. It is evaluated in reverse order on linux64. @klickverbot Exactly. Document intended behavior + mention that the implementation is flawed on the topic. |
On 30 September 2012 22:37, David Nadlinger notifications@github.comwrote:
While my view is that specificing order of evaluation as something that is For instance, how do we deal with code that silently depends on RTL order Do we reverse the order of named parameters to bring the desired effect?
Maybe I'm thinking too hard about it all. :-) |
Yes, but we're already creating temporaries in some cases.
Not sure if I understand you correctly but if you mean things like |
It make sens to evaluate everything LTR. |
@andralex Thoughts? At this point, I'd say it's pretty clear that we want LTR evaluation and that the docs should be our spec - most of the compiler developers who have weighed in seem to agree. @jm Can you alter the pull request slightly so that it mentions that DMD currently does not implement the specified behavior? |
I can do that. |
Evaluation order of function arguments
Merged, thanks. A page in history has turned. Halfway. |
According to TDPL p. 50 (section 2.3.5.3 Function Call) function
arguments are evaluated left to right. This commit fixes the examples in
the documentation where it is assumed that the evaluation order is
unspecified.
I do not know what's the current behavior of dmd regarding function argument evaluation order and whether d-programming-language.org concerns the specification or the current reference implementation. Depending on this you may ignore this request.