News for hackers. Stuff that matters.
Re:Show HN: a Lisp that uses JSON instead of S-expressions (... by arethuza on Tuesday November 29, 2011 @11:33AM (#3290950)
I really like Lisp (I was even paid to develop in it for 6 years) and these days I love JSON because of its Lisp-ish nature - but those expressions look damn ugly to me.
Re:Show HN: a Lisp that uses JSON instead of S-expressions (... by akkartik on Tuesday November 29, 2011 @01:41PM (#3291556)
You could lose the quotes around strings, but you'd still have the commas.

Maybe start with lisp and just add {key: value key2: value2} syntax for tables? It'd be useful to get ruby-style keyword args for free, at least.

I spend a lot of time thinking about keyword args because I've been working on a lisp interpreter that supports them. Here's a webserver that is nice to read because of a crucial keyword arg (it starts with a colon):

http://github.com/akkartik/wart/blob/460565a2e0/064http-serv...

Like in python the keyword arg is always optional. You could delete it from this definition and it would behave the same.

In conclusion: please try to include python-style keyword args in your next language. You never know when they'll come in handy.

Re:Show HN: a Lisp that uses JSON instead of S-expressions (... by arethuza on Tuesday November 29, 2011 @02:24PM (#3291756)
Common Lisp already has hashtables (not to mention simple association lists) what it doesn't have is a standard syntax for them. However, this is pretty easy to add with reader macros, for example:

http://frank.kank.net/essays/hash.html

Re:Show HN: a Lisp that uses JSON instead of S-expressions (... by anghyflawn on Tuesday November 29, 2011 @02:18PM (#3291727)
What's wrong with Common Lisp's keyword arguments? I'm not being snarky, just asking. I'd say CL works at least as well as Python in this respect.
Re:Show HN: a Lisp that uses JSON instead of S-expressions (... by akkartik on Tuesday November 29, 2011 @02:42PM (#3291834)
No, in Common Lisp you can't mix a keyword arg for a non-keyword param, or vice versa.
Re:Show HN: a Lisp that uses JSON instead of S-expressions (... by sedachv on Tuesday November 29, 2011 @03:17PM (#3291964)
You can do (&rest all-args &key keyword1 (keyword 2 default2)) and then try to figure out all-args in the function body.

How does Python handle mixing order of specifying keyword args positionally and with a keyword?

Re:Show HN: a Lisp that uses JSON instead of S-expressions (... by akkartik on Tuesday November 29, 2011 @03:56PM (#3292136)
Python requires all args following a keyword arg to be keyword args:

  >>> def foo(a=0, b=1, c=2): return [a, b, c];
  ... 
  >>> foo(34)
  [34, 1, 2]
  >>> foo(b=34)
  [0, 34, 2]
  >>> foo(b=34, 35)
  File "<stdin>", line 1
  SyntaxError: non-keyword arg after keyword arg
I chose instead to simply bind args by position after keyword args have been taken:

  wart> (foo :b 34 35)
  (35 34 2)
Re:Show HN: a Lisp that uses JSON instead of S-expressions (... by arethuza on Tuesday November 29, 2011 @02:51PM (#3291870)
Couldn't you write a macro to call functions using whatever mixture of keyword and non-keyword params you wanted?

Or perhaps using some CLOS magic do to do this behind the scenes, e.g. no-applicable-method

http://www.lispworks.com/documentation/HyperSpec/Body/f_no_a...

[NB It's been a long time since I did much Lisp]

Re:Show HN: a Lisp that uses JSON instead of S-expressions (... by akkartik on Tuesday November 29, 2011 @03:12PM (#3291938)
Yes, that's basically what my repo does. It started out as an attempt to build 'arc using macros atop Common Lisp' like the original critics claimed could be done. I pretty much succeeded (and I've been told it's very readable) except that I ended up with a lisp-2. (Lately I've been building it in naked C to get out of that constraint: http://github.com/akkartik/wart/tree/unstable)

I wasn't aware of no-applicable-method; thanks for that pointer.

Re:Show HN: a Lisp that uses JSON instead of S-expressions (... by spacemanaki on Tuesday November 29, 2011 @02:45PM (#3291847)
> Maybe start with lisp and just add {key: value key2: value2} syntax for tables? It'd be useful to get ruby-style keyword args for free, at least.

This is how Clojure hacks around keyword args, and altho destructuring kind of makes up for it, it's not that pretty. (It's not pretty in Ruby either) Hash table literals are a nice addition to Lisp but I think it's kind of ugly to use them for keyword args.

Re:Show HN: a Lisp that uses JSON instead of S-expressions (... by akkartik on Tuesday November 29, 2011 @02:46PM (#3291851)
Ah, that's good to know, thanks.