Charles Childers


blog | parable | retro | ios apps | fountain pens


Syntax for Naming Functions

In Retro (with its Forth roots), a function definition is setup like this:

: name .... code .... ;

The : function parses for a name and turns the compiler on. ; turns the compiler off.

In Parable things are different. There's no direct access to the input stream and things are expected to be arguments from the stack. So we take a quote and a name, and : attaches the name to the quote:

[ .... code .... ] 'name' :

In the upcoming 2016.02 release of Parable there's a second form, this time setup opposite. E.g.:

'name' [ .... code .... ] .

From a Forth background, I like : - I already associate it with function creation, and the stack effect is interestingly reversed from a normal Forth approach. But I see some value in the . form as well: it may be more readable in cases where a lot of functions are being created and reads somewhat like a phrase.

For the forseeable future both forms will be supported. If you have a preference, please contact me (email or twitter preferred).