Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Functional > Re: Better synt...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 17 Topic 2768 of 2841
Post > Topic >>

Re: Better syntax for a Standard ML derivative

by torbenm@[EMAIL PROTECTED] (Torben =?iso-8859-1?Q?=C6gidius?= Mogense Feb 19, 2008 at 06:17 PM

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




 17 Posts in Topic:
Better syntax for a Standard ML derivative
"David B. Benson&quo  2008-02-11 17:42:18 
Re: Better syntax for a Standard ML derivative
Paul Rubin <http://phr  2008-02-11 18:24:30 
Re: Better syntax for a Standard ML derivative
torbenm@[EMAIL PROTECTED]  2008-02-19 18:17:38 
Re: Better syntax for a Standard ML derivative
"David B. Benson&quo  2008-02-12 11:02:55 
Re: Better syntax for a Standard ML derivative
Paul Rubin <http://phr  2008-02-12 12:55:35 
Re: Better syntax for a Standard ML derivative
Jon Harrop <usenet@[EM  2008-02-12 20:22:44 
Re: Better syntax for a Standard ML derivative
"David B. Benson&quo  2008-02-12 16:32:28 
Re: Better syntax for a Standard ML derivative
Paul Rubin <http://phr  2008-02-12 16:42:18 
Re: Better syntax for a Standard ML derivative
"David B. Benson&quo  2008-02-12 17:53:04 
Re: Better syntax for a Standard ML derivative
Donn Cave <donn@[EMAIL  2008-02-14 10:02:03 
Re: Better syntax for a Standard ML derivative
"David B. Benson&quo  2008-02-14 11:55:30 
Re: Better syntax for a Standard ML derivative
"David B. Benson&quo  2008-02-19 11:34:49 
Re: Better syntax for a Standard ML derivative
Paul Rubin <http://phr  2008-02-19 12:21:40 
Re: Better syntax for a Standard ML derivative
"David B. Benson&quo  2008-02-19 13:54:23 
Re: Better syntax for a Standard ML derivative
Paul Rubin <http://phr  2008-02-19 14:06:41 
Re: Better syntax for a Standard ML derivative
"David B. Benson&quo  2008-02-19 14:48:40 
Re: Better syntax for a Standard ML derivative
"David B. Benson&quo  2008-02-19 14:50:59 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 8:54:05 CDT 2008.