2 ms·
And yet so many RPN people are Lisp programmers the rest of the time. I guess it balances out.
by brians 9y ago
And yet so many RPN people are Lisp programmers the rest of the time. I guess it balances out.
- thomastjeffery 9y agoI would really like a postfix lisp. I wonder what edge cases I would run into designing one.
- macintux 9y agoAren't concatenative languages like Forth and Factor essentially what you're looking for?
- thomastjeffery 9y agoThey are very focused on the stack, which isn't very lispy. I was wondering how difficult it would be to make a common lisp or scheme, but with postfix syntax instead of prefix.
- kazinator 9y agoWe could start by tinkering with a silly macro: [10]> (defmacro rev (&rest forms) `(progn ,@(mapcar (lambda (form) (if (and (consp form) (rest form)) `(,(car (last form)) ,@(butlast form)) form)) forms))) REV [11]> (rev (1 1 +)) 2 [12]> (rev (3 print) (1 1 +)) 3 2
- kazinator 9y agoStart by writing some small programs in this; what exactly is the syntax? A Lisp macro (rpn ...) could provide a DSL whereby all the forms in ... are recursively code walked and turned from a postfix notation into a regular Lisp notation. You probably want the walker not to fiddle with expressions like '(a b c) quoted lists. That creates a special case to handle. You have to know that (quote (a b c)) is in a context where it is evaluated (which normally undergoes rpn to Lisp transformation) and so should be left alone. You don't want (quote z) being treated as RPN denoting (z quote)! Likewise, you don't want #'foo, which is (function foo) to be turned into (foo function). So, basically, a code walker is needed which knows what is evaluated and what isn't, which leaves alone stuff that isn't evaluated, and also avoids RPN-to-lisp-transforming certain expressions that are evaluated.