Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit) (+1)

I've never understood the difference between :done; and :return; The doco implies that :return; is used to return from a subroutine, so that's how I've used it. I now use :done; everywhere else.

When using :done; always make sure you print something beforehand or you'll end up with a blank line. I've also gotten into the habit of liberal use of :done; to make sure that my specific pattern-matching routines do not fall through to the generic pattern-matching routines and ending up with two responses.

(+1)
  • : return will return from a subroutine but continue executing code after the : gosub ""; command that was used to call it.
  • : done will stop the code dead in its tracks (not return to the line after the gosub).

Executing any line (including a terminator) will override the system default handler for the text entered. I plan to add a default message for when done is executed without printing something first (overridable).

(+1)

Aha. That makes sense within the context of subroutines, but don't they act the same in :match{} routines?

No, a return is exactly the same as a done, except in a subroutine. There is nothing to break out of a match specifically.