Re:Lisp implementation in sed
by bndr on Friday June 27, 2014 @06:12PM
(#7956519)
This is amazing. Just reading the code makes my head hurt, but you implemented a language with it.
[ Parent
| on HN ]
Here, for example, is the implementation of `atom` (I think):
/(atom /{
/\[\S\+\]/{
s/.*/[]/
bpop_context
}
s/.*/t/
bpop_context
}The way you can nest conditions in sed, like /foo/ { /bar/x }, is pretty powerful, and I knew a good bit of sed before I realized you could do that. It's not readily obvious from the manual.
The author has won an IOCCC contest. This would have just pricked him a bit.
If this was (the only available) programming, I'd quit.
Kudos, I think, to the author. His pain tolerance exceeds mine by a vast amount.
> If this was (the only available) programming, I'd quit.
We started with nothing, remember? Just the bare metal. If this were the only available programming, I'd write an interpreter for a better language.
Never imagine that your current suite of tools is all there is.
It will be a challenge to make an interpreter for a better language faster than dead slow.
I would bet on a compiler for a better language instead. That way, only one person would have to wait ages and ages. I doubt the result would be fast, but it wouldn't be insanely, insanely, insanely slow, either.
I would much rather hand assemble machine code than program in sed. I imagine most people have a better understanding of how computer architecture works than how to do arithmetic and logic with sed.