I have already blogged about the reading order of programming languages. Thinking about that, a stupid idea formed in my head:
What if Lisp had pipes?
You know, pipes, as in “|
“. These fabulous little things known from such nice expressions like “grep whatever * | more
” or “cat stuff | sort | uniq
“.
Now, imagine how bad the last example would look, if the unix shell was lisp-like: (uniq(sort(cat stuff)))
. (Well, maybe bad is the wrong word. Still, I think it looks considerably cleaner in shell-syntax.)
Now, if Lisp had my proposed, to-be-implemented, pipe-enabling, world-changing, preprocessor, it would look like this: cat stuff | sort | uniq
– which is in fact identical to the shell version. Piping a command into another one would be the equivalent of using it (the first one) as the 2. command’s parameter. Like so: (define ls (list 1 2))
could become list 1 2 | define ls
.
As you can see, that wouldn’t change or break a lot – it would just give us programmers a way to more-or-less reverse the reading order of expressions. Which could come in handy in those case where Lisp’s natural order reads awkwardly inverted.
In case you asking: I am fully aware of the fact that – with the examples given above – this looks neither helpful, nor lispy, nor even remotely like something anybody would want to have.
Well, I’ll be back (with a prototype) to discuss this idea some more. Oh, hacking, you got me back…
Leave a Reply