Live data from Hacker News

Show HN: a Lisp that uses JSON instead of S-expressions (in .js)

github.com

71–74 of 74 posts

Re: Show HN: a Lisp that uses JSON instead of S-expressions (in .js)

#71
post #19
post #8

I still think there's room for experimenting with a Lisp that has the hashmap (a.k.a. dictionary, associative array, property bag) as its organizing principle rather than the list. There's nothing better than hashmaps for exploratory programming. If there is something to be gained from building a Lisp in terms of them (from the ground up; I don't mean support for object literals), I'd like to know what it is. This ha…

This presents a very thorny language design problem. Lists have this very nice property that they are ordered , which lets you attach implied semantics to the position of an element, e.g.: (defun foo (a b c) ...) We know this is a function defining because the symbol DEFUN is in the FIRST position of the list. Associative arrays are unordered, so you have to explicitly label everything: { top-level-form : defun, argu…

> Exercise for the reader: what happens if you base a Lisp-like language on vectors instead of cons cells?

I've been thinking about this in terms of a self-hosted Parenscript. What I see is a lot more pattern matching and map/reducing. Not altogether a bad thing.

Re: Show HN: a Lisp that uses JSON instead of S-expressions (in .js)

#72
post #31

Earlier quoted context omitted.

> Could you allow (a b c) as a synonym for { 0 a 1 b 2 c }? Yes, of course, but all you've done is re-invent vectors. > you lose cdr (except by copying the rest of the vector) Copying the rest of the vector is not semantically equivalent to CDR unless you are being purely functional. But you can actually implement CDR using displaced vectors. > You must have something in mind other than this? Could be :-) Try writing…

> In particular, when you're done, make a list of all the primitives you needed to employ in order to do it. There's a deep insight at the end of this process. (No, I'm not going to tell you what it is.) Having done this before ( https://github.com/munificent/lark ), all it meant for me was that numbers and basic integer arithmetic became primitive. The clever bit about McCarthy's original metacircular interpreter is…

I suppose depth is in the eye of the beholder. That's pretty much it: to build a Lisp out of vectors you need numbers as primitives. To build a Lisp out of cons cells you don't.

Follow-up exercise: do you need numbers to build a Lisp out of associative arrays? (Hint: this is not a trivial question to answer.)

Re: Show HN: a Lisp that uses JSON instead of S-expressions (in .js)

#73
post #72

Earlier quoted context omitted.

> In particular, when you're done, make a list of all the primitives you needed to employ in order to do it. There's a deep insight at the end of this process. (No, I'm not going to tell you what it is.) Having done this before ( https://github.com/munificent/lark ), all it meant for me was that numbers and basic integer arithmetic became primitive. The clever bit about McCarthy's original metacircular interpreter is…

I suppose depth is in the eye of the beholder. That's pretty much it: to build a Lisp out of vectors you need numbers as primitives. To build a Lisp out of cons cells you don't. Follow-up exercise: do you need numbers to build a Lisp out of associative arrays? (Hint: this is not a trivial question to answer.)

In Clojure an associative array auto-decomposes to a sequence of pairs when necessary.

Re: Show HN: a Lisp that uses JSON instead of S-expressions (in .js)

#74
post #72

Earlier quoted context omitted.

> In particular, when you're done, make a list of all the primitives you needed to employ in order to do it. There's a deep insight at the end of this process. (No, I'm not going to tell you what it is.) Having done this before ( https://github.com/munificent/lark ), all it meant for me was that numbers and basic integer arithmetic became primitive. The clever bit about McCarthy's original metacircular interpreter is…

I suppose depth is in the eye of the beholder. That's pretty much it: to build a Lisp out of vectors you need numbers as primitives. To build a Lisp out of cons cells you don't. Follow-up exercise: do you need numbers to build a Lisp out of associative arrays? (Hint: this is not a trivial question to answer.)

Rereading McCarthy's paper yesterday I noticed for the first time that it didn't need numbers. But I hadn't connected all the dots yet.
Post reply on HN