Commit 8166d83
committed
ScriptModule: improve handling of return values
Whether the return value output is explicitly declared makes a big
difference. The behavior we want is:
implicit output explicit output
/--------------------------------------------------\
| result = 2 | // @output int result |
variable | 1 | result = 2 |
assigned | | 1 |
| | |
| BEHAVIOR: result is 1 | BEHAVIOR: result is 2 |
|-----------------------+---------------------------
| 1 | // @output int result |
variable | | 1 |
unassigned | | |
| BEHAVIOR: result is 1 | BEHAVIOR: result is null |
\--------------------------------------------------/
The thinking is that when the script writer declares an output called
"result", their intuition will be that the final assignment to the
variable called "result" should become the output value. But when they
_don't_ explicitly declare that output, the implicitly added output
called "result" refers to the return value of the script itself, not
the value of the variable called "result" in the bindings.1 parent a9dfd50 commit 8166d83
File tree
2 files changed
+18
-9
lines changed- src/main/java/org/scijava/script
2 files changed
+18
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| |||
207 | 210 | | |
208 | 211 | | |
209 | 212 | | |
| 213 | + | |
210 | 214 | | |
211 | 215 | | |
212 | 216 | | |
| |||
233 | 237 | | |
234 | 238 | | |
235 | 239 | | |
236 | | - | |
| 240 | + | |
237 | 241 | | |
238 | 242 | | |
239 | 243 | | |
| |||
243 | 247 | | |
244 | 248 | | |
245 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
246 | 255 | | |
247 | 256 | | |
248 | 257 | | |
| |||
347 | 356 | | |
348 | 357 | | |
349 | 358 | | |
| 359 | + | |
350 | 360 | | |
351 | 361 | | |
352 | 362 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
193 | 198 | | |
194 | 199 | | |
195 | 200 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 201 | + | |
203 | 202 | | |
204 | 203 | | |
205 | 204 | | |
| |||
0 commit comments