|Given that layout has been used in Miranda, Haskell, etc., to determine
|when one thing ends and another begins, it might be worth trying the
|same idea within expressions.  The suggestion is that any subexpression
|that contains no white space but is surrounded by white space has
|implied parentheses around it.  Hence
|
|f x!i would parse as f (x!i)
|
|This would make functions definitions with pattern matching easier too.
|For example, we could write:
|
|sum x:xs = x + sum xs
|
|instead of
|
|sum (x:xs) = x + sum xs
|
|I'm not completely convinced myself, but thought it was an idea worth
|floating.
|
|Warren

Mark Wells reported, in a paper in SIGPLAN Notices a few years ago,
using a similar scheme in the language Modcap.  (A funny thing about
this paper is that he attributes the idea to me, and I don't recall
suggesting any such thing!)  In, Modcap, I believe, the notion was that
white space surrounding an operator modified its syntactic precedence,
so that an operator with space around it had a lower precedence than
any without space.  Mark also noted that the scheme could be extended
to allow larger amounts of white space to imply yet lower precedence
levels, but they didn't implement this extension and weren't convinced
of its benefits.

Frankly, the idea frightens me (which is why I was a bit perturbed
at having it attributed to me :-), but Warren has a good point about
its being consistent with layout.  By the way, Mark reported that
their experience with this trick was quite positive.

--Joe

Reply via email to