Skip to content

Remove fun, and use let to declare functions #313

@julianhyde

Description

@julianhyde

Remove fun, and use val to declare functions (even functions that are recursive and/or have multiple arms). Introduce new nonrec keyword to explicitly specify that a value declaration or function declaration is non-recursive. After this change, rec is implicit if there is one or more argument, nonrec is implicit if there are no arguments.

For example,

fun factorial 1 = 1
   | factorial n = n * (factorial (n - 1))

becomes

val factorial 1 = 1
  | factorial n = n * (factorial (n - 1))

Currently, recursion works because fun desugars to let rec. After this change, rec would be implicit if there is one or more argument; nonrec would be implicit if there are no arguments.

The following is valid Standard ML and will remain valid Morel.

val x = "abc";
> val x = "abc" : string
val x = size x;
> val x = 3 : int

If we implement #307, val will become let, and the let ... end block will become { ... }.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions