Re: safe call evaluates arguments first?
OCsite <[email protected]> Sat, 29 Mar 2025 18:01:14 +0100
| Newsgroups | gmane.comp.lang.groovy.user |
|---|---|
| Message-ID | <[email protected]> |
https://issues.apache.org/jira/browse/GROOVY-11591 > On 28. 3. 2025, at 17:26, Jochen Theodorou <[email protected]> wrote: > > please add an issue > > On 3/28/25 00:10, OCsite wrote: >> Thanks! >> >> Should I add a jira? Or will you? Or not worth one? >> >> All the best, >> OC >> >>> On 27. 3. 2025, at 21:28, Jochen Theodorou <[email protected]> wrote: >>> >>> 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 >>> >> >