GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸŽ€ GOLF(2gg) β€” return-handler πŸ’–

okay bestie, gather round, because this one is so important and it's giving main character energy for real.

✨ NAME ✨

return-handler β€” (program-flow) 🌸


πŸ’… PURPOSE πŸ’…

Bounce out of the request handler you're currently in and go back to whoever called you. that's it. that's the whole vibe. πŸ¦‹


✨ SYNTAX ✨

return-handler  [ <return value> ]

🌈 DESCRIPTION 🌈

so return-handler returns from the current request handler by handing control back to its caller. simple! iconic! πŸ’–

but here's where it gets spicy, because how it returns depends on what kind of request you're handling:

  • If the current request handler is handling an external request (like from a web browser, an API, a command line, etc.), then return-handler is literally equivalent to exit-handler. same thing, no cap. ✨
  • If the current request handler was handling an internal request β€” meaning it got called from another request handler via call-handler β€” then control transfers back to that handler immediately after the call-handler. like, right after. no detours. 🫢

For internal requests, that number <return value> gets passed back to the caller, and the caller can grab it with the "return-value" clause in call-handler. πŸ‘‘

  • If <return value> is omitted, it's assumed to be 0. default behavior, we love her. πŸ’œ
  • If the current request handler is handling an external request, then <return value> will also set the handler's exit status (peep exit-status and exit-handler for the deets). πŸ”₯

πŸ“ EXAMPLES πŸ“

In this example, "req-handler" (the caller) will call "other-handler" (the callee), and the callee will return to the caller β€” immediately after call-handler. here's the caller, slaying:

begin-handler /req-handler public
    ...
    call-handler "/other-handler" return-value rval
    ...
end-handler

and here's the callee handler, doing her little exit:

begin-handler /other-handler public
    ...
    return-handler 5
    ...
end-handler

The value of "rval" in the caller will be 5. ✨ that's it, that's the magic. πŸ’«


πŸ¦‹ SEE ALSO πŸ¦‹

Program flow

break-loop call-handler code-blocks continue-loop do-once exit-handler if-defined if-true quit-process return-handler start-loop β€” See all documentation πŸ’–


mwah, that's the whole page bestie πŸ’œ this one came from the $DATE drop, version $VERSION, filed under GOLF(2gg) β€” go forth and return-handler responsibly, ily πŸŽ€βœ¨

πŸ“¦ where this page comes from