Live data from Hacker News

Lisp implementation in sed

github.com

11–20 of 64 posts

Re: Lisp implementation in sed

#11

Would someone mind giving a quick explanation of how this works? I have only used sed to replace text in files and directories. How do people write interpreters and game loops with this unix utility?

With difficulty.

I started playing with the idea of making a programming language out of sed at one point, but then I decided that, even if I succeeded, it would be a waste of time.

I didn't take into account Hacker News.

Re: Lisp implementation in sed

#13
post #8

Earlier quoted context omitted.

I wrote that, and I gotta say sed is a much crazier target. More sed fun: http://aurelio.net/projects/sedsokoban/

Indeed. There are few wide-spread programming languages around any more that lack such things as, say, any form of arithmetic whatsoever.

sed has regular expressions. I think you could do some binary arithmetic fairly easily with regular expressions and find and replace...

Re: Lisp implementation in sed

#14
post #5
post #3

This is amazing. Just reading the code makes my head hurt, but you implemented a language with it.

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.

Re: Lisp implementation in sed

#16

Would someone mind giving a quick explanation of how this works? I have only used sed to replace text in files and directories. How do people write interpreters and game loops with this unix utility?

the sed language allows conditional jumps to labels. That makes it powerful enough to write programs in.

If you had to just write programs by running a series of sed substitution expressions to a file over and over, and not use conditionals... it might still be possible to program in. Much harder to think about, though.

Re: Lisp implementation in sed

#18

Would someone mind giving a quick explanation of how this works? I have only used sed to replace text in files and directories. How do people write interpreters and game loops with this unix utility?

With difficulty. I started playing with the idea of making a programming language out of sed at one point, but then I decided that, even if I succeeded, it would be a waste of time. I didn't take into account Hacker News.

woah woah woah. we don't just throw around "waste of time" like that :)

Re: Lisp implementation in sed

#19
post #17
post #15

Now you have three problems.

Oh come on. They took an unreadable language and implemented a slightly less unreadable language in it. That's at least two problems and one solution. To what, I don't know.

did I misinterpret or did you just call lisp "[nearly] unreadable"? all languages are unreadable for the uninitiated.

Re: Lisp implementation in sed

#20
post #17

Earlier quoted context omitted.

Oh come on. They took an unreadable language and implemented a slightly less unreadable language in it. That's at least two problems and one solution. To what, I don't know.

did I misinterpret or did you just call lisp "[nearly] unreadable"? all languages are unreadable for the uninitiated.

You didn't misinterpret.
Post reply on HN