Re: safe call evaluates arguments first?
Jochen Theodorou <[email protected]> Thu, 27 Mar 2025 21:28:07 +0100
| Newsgroups | gmane.comp.lang.groovy.user |
|---|---|
| Message-ID | <[email protected]> |
On 27.03.25 18:11, [email protected] wrote: > Hi there, > > I've just bumped into this behaviour, as shown e.g., by the code quoted below. A safe method call first evaluates method's arguments, and only then trashes the call. I think we do in general: * push arguments on stack * push receiver on stack * write method call and for the safe variant we probably do: * push arguments on stack * push receiver on stack * write jmp if null * write method call * jmp to after call * marker for null case * remove elements from stack * push null * marker for after call > Is this the intended behaviour? It would seem to me much better if the arguments were not evaluated in this case (precisely same way as if we used the java-like “if (obj) obj.whatever...” approach instead of the safe call) — but perhaps I am overlooking something of importance. expected yes... correct is the other question, because I am with you, this should be like the if-variant bye Jochen