Skip to content

TM003 Prefer words over symbols in syntax, and change lambda syntax

Daniel Patterson edited this page May 30, 2013 · 2 revisions

Motivation:

One of the design goals of Pyret is to have most syntax be expression forms that can be passed to functions, assigned to variables, etc. This means that they should be readably when surrounded by commas and parenthesis. This proposal claims that pairs of symbols next to each other that are not one syntactic identifier are harder to read and that we should prefer words in syntax to avoid this.

As a concrete example, we want to replace the lambda syntax with 'fun'. The motivation is both that it is easier to read when embedded within other expressions and that it uses the same token as regular functions.

Example:

list.fold(\a, b: (\c: (b(a))), some-list, \c: c)

would become:

list.fold(fun(a,b): fun(c): b(a) end end, fun(c): c end)

Which seems much easier to parse. Simpler examples are even better:

list.fold(\a, b: (b.plus(a)), some-list, 0)

would become

list.fold(fun(a,b): b.plus(a) end, some-list, 0)

Specification:

Instead of:

\arg[, arg]*: (e)

Lambdas will be written as:

fun(arg[, arg]): e end

Resolution:

Lambda syntax changed as of 58f92e1ce4531379e7c11cd8fef05b12c3a057e3, general consensus in favor of keywords.