| 266 | Pseudocode for return/result handling, parallel to arg/param handling: |
| 267 | |
| 268 | {{{ |
| 269 | Infinite loop |
| 270 | Get next result slot |
| 271 | Get next return value |
| 272 | |
| 273 | If there are no more returns |
| 274 | if there are no more results |
| 275 | we're done, no error |
| 276 | else |
| 277 | error, too many positional returns |
| 278 | |
| 279 | If result slot is slurpy |
| 280 | if result slot is named |
| 281 | end positional loop (handle named slurpy in named loop) |
| 282 | create a new array PMC |
| 283 | Loop over all remaining positional returns |
| 284 | Insert positional into slurpy array |
| 285 | put the slurpy array in result slot |
| 286 | break loop (all positionals used up) |
| 287 | |
| 288 | if have more results to fill |
| 289 | if result is named |
| 290 | fill result slot with positional return |
| 291 | mark name as used |
| 292 | else if we have already seen a named result |
| 293 | error, positionals must be before named |
| 294 | add return to next result slot |
| 295 | if result slot is optional |
| 296 | set the corresponding opt_flag to 1 |
| 297 | |
| 298 | else if result is optional |
| 299 | if result is named |
| 300 | break loop (handle named in named loop) |
| 301 | set the corresponding opt_flag to 0 |
| 302 | |
| 303 | else |
| 304 | if result is named |
| 305 | break loop (handle named in named loop) |
| 306 | error (too few positional returns) |
| 307 | |
| 308 | Loop over remaining returns |
| 309 | if return is not named |
| 310 | error (all remaining returns should be named) |
| 311 | store named return in temporary named returns hash |
| 312 | |
| 313 | Infinite loop |
| 314 | get next result slot |
| 315 | |
| 316 | if result slot is not named |
| 317 | error (positionals must come before named) |
| 318 | |
| 319 | if result slot is slurpy |
| 320 | if temporary named returns hash is not null |
| 321 | put temporary named returns hash in result slot |
| 322 | else |
| 323 | put new empty hash in result slot |
| 324 | |
| 325 | get result slot name |
| 326 | if the name has an element in temp named returns hash |
| 327 | get next result slot |
| 328 | put return value in result slot |
| 329 | delete the entry from the temp named returns hash |
| 330 | if result is optional |
| 331 | set the corresponding opt_flat to 1 |
| 332 | else if the result is optional |
| 333 | set the corresponding opt_flat to 0 |
| 334 | else if error checking is on |
| 335 | else (too few named returns) |
| 336 | |
| 337 | if there are any items left in the temporary named returns hash |
| 338 | loop over temporary named returns hash |
| 339 | collect key names for error message |
| 340 | error (too many named returns) |
| 341 | |
| 342 | }}} |