Ideas for a better Worst
Hi,
First of all, love the name of this language, it's awesome ! Secondly, if you're interested, I'd like to propose a feature for Worst, that I think may fit into the whole Lisp/Forth/Tcl paradigm. I've implemented it for some stack-based languages of my own, and it finds interesting uses pretty much everywhere.
You'll have noticed that, since variables aren't bound to a scope, they can't be captured by a function. That means that functions all have to be static, because they could technically be called in any environment. But what if they could, at the time of their creation, "absorb" some information from the stack and create specialized versions of themselves each time they're pushed ?
We can steal some ideas from Lisp's backquotes for the notations, and define ,[code...]
to be a notation for a "hole" that can be filled when the function is pushed on the stack (by other values on the stack). With this notation, if you write [ ,[x1] .. ,[xn] ]
, it's equivalent to writing [x1 .. xn]
, except now you can do funkier things like
create a function that runs a block of code, and then restores the environment to what it was before that block was run, like [ [ ,[] exec ,[save-state] restore-state ] exec ]
(useful for encapsulating modules, for example). Other examples abound.
There are some examples of that feature in action on this site I'm working on which uses a similar stack-based language (except I quote with { ... }
and unquote with {@ ... @}
). It's a bit terse, but you can perhaps get a better feel of the feature with an interpreter to play with ;-)
Anyway, I give my best to Worst, and bid you a good morrow,