SML coding style

Stephen Weeks sweeks@intertrust.com
Wed, 21 Jun 2000 16:11:58 -0700 (PDT)


Matt, if I can make a request about coding style without seeming
overbearing.  Please do not use the style of function declaration
where the function name is duplicated.  This style hard to type, hard
to read, and hard to edit.

Rather than

fun foo A = 1
  | foo B = 2
  | foo C = 3

it is much better to have

val foo =
  fn A => 1
   | B => 2
   | C => 3

or even

fun foo x =
  case x of
     A => 1
   | B => 2
   | C => 3

If foo is recursive, val rec can be used.  Both of the forms that I
gave also have the advantage that you do not have to parenthesize the
pattern when it is a constructor application.

Thanks.