Prime Lisp
September 25, 2016
DRAFT
I was reading recently about the differences between a so-called Lisp1 and a Lisp2. I am not sure I’m 100% on the differences yet. The basic distinction is that a Lisp1 has a common function and variable namespace, where as a Lisp2 has two separate namespaces. Some consider the later superior in that it avoids name clashes between function and variable names. While others think this is not as important as the ramifications. In a Lisp2 reference to functions have to be designated, typically via #'.
(sort (list 5 2 6 3 1 4) #'compare)
Where as in a Lisp1 you can just do:
(sort (list 5 2 6 3 1 4) compare)
On the other hand, in a Lisp1 you can’t use list as a variable name because its already a function name (that you just might need).
Let’s consider another example, this time with variables. In a Lisp2 one would write
(mapc #'print '(a b c d))
In a Lisp1, its
(mapc print '(a b c d))
I assume that in the Lisp2, print needs the #' because otherwise it could be mistaken for a variable, albeit undefined (and thus an error?).
I had a silly notion that sort of bridges the divide, so to speak, although maybe not in the most elegant of fashion. The idea makes two changes to the language:
- All function calls end in a prime mark, eg.
f'. - All variable references are shadowed, e.g.
a_.
So in my “Prime Lisp” the above two examples would be:
(sort' (5 2 6 3 1 4) >)
and
(mapc' print (a_ b_ c_ d_))
Not very elegant, I admit, but it has some neat ramifications. Not only are functions and variables in their own namespace (obviously), hence a Lisp2, but print doesn’t need the #' cruft, hence a Lisp1. In fact symbols in Lisp’ become unadulterated! That’s pretty spiffy – except of course it unspiffies everything else :wink:
But wait wait! There’s more! My silliness knows few bounds. To respiffy the unspiffiness we’ve created (yea, I’m dragging you into this), let’s get typologically moder already and italicize atoms ending in ' and bold those shadowed. Our examples would then look like like
(mapc print (a b c d))
Well isn’t that special. Btw if you are wonder why we even bothered to put the punctuation marks after the words instead of before. It makes it easier to handle in a text editor, you won’t be able to see these marks but they will act like they are there. Backspacing over the invisible ' or _, will change the format. Get it? Am I crazy or what?