Nikodemus Siivola tries to demonstrate the hazards of overenthusiastic blogging about a new tool of expression. Unfortunately his parody doesn't make the point well, because it's too close to being good. I didn't even suspect it was a parody until I got to the first nonsensical bit:
This macro expands into an elegant recursion that constructs a list by repeatedly calling a function with the results of evaluating arguments. The last bit is the key to its power:
;;; no need for this (let ((stream (make-stream))) (---> *n* (composition) stream)) ;;; just this is enough (---> *n* (composition) (make-stream))
Even at that point, I was willing to believe the author had just garbled his explanation. To recognise a piece as parody implies an insult: this is so bad it can't be serious. That's a harsh condemnation to make of code you don't understand. And code in an unfamiliar language can be as impenetrable as merely bad code. I don't think rejection is a good default response to anything difficult or novel.
In other words, the arrow macros I presented were intentionally horrible. If you thought they were neat, think again.
They were horrible in their details, but the basic ideas are right. <---
needs a better name, like iterate
, or unfold
(with a finished-p
argument). --->
is take
and map
with a perverse way of calling its argument. Aside from producing that argument, I can't think of a good use for <-
, but having a short way to write compose
is important. So I thought they were neat. Done wrong, sure, but they're the right thing done wrong. What I saw in the final example was this:
(map - (take 3 (iterate 0 1+)))
Apparently Nikodemus can't write wholly bad code if he tries.
No comments:
Post a Comment
It's OK to comment on old posts.