breuleux / liso

Operator syntax for the Lisp family of languages (Racket implementation)
31 stars 4 forks source link

Don't use commas (or make them optional)? #1

Open greghendershott opened 10 years ago

greghendershott commented 10 years ago

This is awesome. One question:

A nice thing about s-expressions is not needing to type commas between items in a list; space suffices.

Would it be possible to eliminate commas? Or at least make them optional? (Or as optional as possible?)

If the multi-line variant can do this with \n, it seems like the one-line variant should be able to do it with ? (Otherwise, the one-line variant is, ironically, less concise.)

breuleux commented 10 years ago

The idea that s-expressions are more concise is a bit illusory here, since (a b c d) and (a b,c d) are the same length. Sure, you'd add a space anyway, but that's just a stylistic choice :)

Now, the problem is that I cannot eliminate commas without making the language less internally consistent. The current semantics of juxtaposition is apply. This means that min xs translates to the s-expression (apply min xs). This is an important aspect of the syntax because it explains why function application looks the way it does: f(x) translates to (apply f (list x)), which is equivalent to (f x). You could write args = (x), f args and it'd work just the same. It is not a special case.

But under your proposal, (min xs) would translate to (list min xs). That is not consistent, and my goal with Liso is not to cater to s-expressions but to maximize internal consistency: juxtaposition always means the same thing, every single line break is interpreted as a comma, every single indented block is interpreted as a {} block, all types of brackets have the same semantics everywhere, etc. Even from a pragmatic standpoint, I suspect that the syntax is more likely to be successful with people used to languages like Java or Python who are used to commas, than from Lispers who are already comfortable with s-expressions and don't really have an incentive to switch.

There might be something to do with (currently unused) square brackets, though. One thing I could do is repurpose () so that it switches to s-expression syntax, and use [] for what I'm currently using () for. Then you'd have the choice between f[x, y] and (f x y).