Paul Rubin <http://phr.cx@[EMAIL
PROTECTED]
> writes:
> If you're going to rework SML syntax, I think it's better to rework
> it radically than tweak it here and there.
I agree. Here are some thoughts I have previously had on this
subject:
- Make types look more like values (like in Haskell), so a pair type
is written (A,B) instead of A*B and a list type is written [A]
instead if A list, etc.
- Unify sequencing and binding:
x = e1; e2 replaces let val x = e1 in e2 end
e1; e2 replaces (e1; e2)
Note that this requires that x = e1 is not an expression, so = must
be made into a reserved "keyword" and the equality comparison must
be replaced by, say, ==. ; should associate to the right, so you
get naturally nested bindings with, e.g., x = e1; y = e2; e3. This
syntax does require unbounded lookahead when parsing (same problem
as in Haskell's list comprehensions), but as long as the syntax is
unambiguous I don't mind long lookaheads -- human readers can handle
long lookaheads.
- Don't require "and" in mutually recursive bindings. Let all
bindings at the same level be automatically mutually recursive.
This requires you to use different names where you could otherwise
reuse a name, but I don't see this as a problem. The compiler
could figure out dependencies so you don't get too many polymorphic
recursion restrictions. Haskell does this.
- Drop the "fun" and "val" keywords, but make constructors lexically
distinct from function names and variables (e.g., by case
distinction as in Haskell or Prolog). This way, f x = e is a
function definition, while F x = e is a value binding with pattern
matching.
- Make infix operators lexically distinct from variable names, so you
can parse a sequence of three symbols without having to know if the
middle is declared infix. Have a fixed number of precedences and
let the first character in a symbol define its precedence. So if
you declare a user operator +=+, it automatically has the same
precedence as +. Several characters (e.g., + and -) may define the
same precedence.
- Use 'c' for character constants. #"c" is just plain ugly.
This is not an exhaustive list, but just what I could recall whiel
typing.
Torben


|