Skip to content
Joe Politz edited this page Jun 22, 2016 · 2 revisions

TM024 - ...

The Design Recipe instructs us to write templates in comments:

#|
fun lon-fun(a-lon :: List<Number>, ...) -> ...:
  cases(List<Number>) a-lon:
    | empty => ...
    | link(first, rest) =>
      ...(... first ..., ... a-lon(rest) ...)
  end
end
|#

But as soon as we lift those comments out and start writing a function, the program becomes a syntax error. This proposal suggests giving the syntax ... a specific meaning to enable a gradual transition from template to implementation.

This proposal only addresses ... in expression position. Depending on the template pedagogy, ... may also appear elsewhere – for instance the first two ...'s in the example above are in binding and type positions. These only appear in function headers, and since the program really ought not to run at all before the header is filled in (doing so comes before writing examples in the design recipe), it's possible to slide past this concern. It would be nice to handle that in the future, but it is more difficult to ascribe a meaning to those ... syntaxes than to ... that appears in expression position.

Syntax

This proposal adds one new expression form. Its concrete syntax is three . characters with no spaces in between. It will parse as a template-expr, or s-template in the AST.

Currently, the well-formedness checker disallows the use of multiple expressions on the same line. This check will be modified to allow multiple expressions on the same line if at least one of them is an ellipses expression, in order to write the kinds of templates we see above.

Semantics

The ellipses expression's semantics is entirely expressed via desugaring. The desugaring is:

s-template(srcloc)

=>

e-app(global-id("throw"), [list: e-app(global-id("err-not-yet-implemented", mk-srcloc(srcloc)))])

or, in concrete syntax:

...

=>

throw(err-not-yet-implemented(srcloc("this-file.arr", <srcloc information>)))

Interaction with Testing

In order to accommodate the desugaring, this addition will include a new dynamic error, err-not-yet-implemented, which takes the source location of the ellipses expression that generated it as its only argument.

This special error can be used to intelligently report testing failures that result from calling a function that isn't implemented yet.