Not logged in
Log in now
Create an account
Subscribe to LWN
LWN.net Weekly Edition for December 5, 2013
Deadline scheduling: coming soon?
LWN.net Weekly Edition for November 27, 2013
ACPI for ARM?
LWN.net Weekly Edition for November 21, 2013
Little things that matter in language design
Posted Jun 8, 2013 15:18 UTC (Sat) by jzbiciak (✭ supporter ✭, #5246)
As I recall, LISP bullies its way out of that with an explosion of parentheses. Haskell looks like it largely avoids that, just glancing at some Haskell code on the net. But I don't know Haskell really at all, so I don't know how it addresses, say, sending the arguments 1, -2 to a function. Without a comma, does that look like the expression "1 - 2" or are there other rules you have to be aware of?
Posted Jun 8, 2013 16:00 UTC (Sat) by SLi (subscriber, #53131)
foo 1 (-2) is parsed as ((foo 1) (-2))
(in Haskell all functions really take exactly one argument; here foo would take an integer and return a function taking an integer, i.e. the type would be Integer -> Integer -> a)
foo 1 -2 would get parsed as (foo 1) - 2, so foo needs to be a function of the type Integer -> Integer.
Posted Jun 10, 2013 0:32 UTC (Mon) by marcH (subscriber, #57642)
This page for instance shows a good few interesting syntax examples in a quite short space
Posted Jun 8, 2013 16:15 UTC (Sat) by mathstuf (subscriber, #69389)
Posted Jun 8, 2013 18:45 UTC (Sat) by jzbiciak (✭ supporter ✭, #5246)
Well, what I was getting at with my LISP comment is that an expression such as a + b * c - d, which needs no parentheses and is completely unambiguous in a C-like language ends up being (+ a (- (* b c) d)) in prefix notation. I went from 0 parentheses to 3 pairs of parentheses.
Now, C has its own problems with its umpteen levels of precedence, problems that tend to lead to excessive parenthesis, but that's really a different conversation.
Posted Jun 9, 2013 23:56 UTC (Sun) by tjc (subscriber, #137)
(Or it would be, if the "bitwise" AND/XOR/OR operators where at a higher precedence level, just below the bit shift operators.)
Posted Jun 17, 2013 10:44 UTC (Mon) by erich (subscriber, #7127)
Now if we could come up with a language that requires both S-expression paramtheses, C-style braces *and* python indentation (maybe also add in brainfuck/whitespace and some visual basic for applications) then we can finally build the ultimate programming language of hell.
Posted Jun 17, 2013 20:03 UTC (Mon) by mathstuf (subscriber, #69389)
Arguments to functions use exactly one space between them (two spaces passes as the second argument).
Posted Jun 20, 2013 13:02 UTC (Thu) by jzbiciak (✭ supporter ✭, #5246)
... and INTERCAL's "PLEASE" keyword!
I would have thought COME FROM would be a better choice for such a language. That, and ABSTAIN to allow for conditional COME FROM.
1 Arguments to functions use exactly one space between them (two spaces passes as the second argument).
I forgot how evil MUMPS was, despite multiple articles on TheDailyWTF about it.
Posted Jun 20, 2013 6:12 UTC (Thu) by dakas (guest, #88146)
And finding a misplaced ) in Lisp code is a masochists job.
M-x check-parens RET
Posted Jun 9, 2013 14:37 UTC (Sun) by joey (subscriber, #328)
Haskell code often also avoids parens via other means. For example, the function
f x = foo (bar (baz x))
could be written as
f x = foo $ bar $ baz x
but is more likely to be written in point-free style as
f = foo . bar . baz
Incidentially, something very like the the Virgil-II tuple access syntax mentioned in the article is also available in haskell via the lens library. Haskell's syntax is well-suited to defining really interesting and useful operators. For example:
ghci> _1 .~ "hello" $ ("","world")
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds