Proposal: Revamped Exports - adamnew123456/spc GitHub Wiki

Implemented!

Revamped Exports

This proposal is meant to solve an existing issue with how export works - namely, that it only works on values, and not on types (or other potential bindings, like namespaces).

In order to alleviate this issue, export should be able to disambiguate values from types. This will be done via the addition of the export specifier, an extra character prepended to the name of the export. These characters are as follows:

  • ' for values
  • * for types

For example, to export both the function print-pair and the type pair-type:

(declare (pair-type (struct (a integer)
                            (b integer)))
         (print-pair (function byte pair-type)))
(export *pair-type 'print-pair)

Resolving Ambiguities

This has the bonus of resolving ambiguities within export, when the type and the function are named the same. Normally, spc can handle these ambiguities on its own (as it turns out, it isn't ambiguous when a type or a value is required), but since export lacks the required context, it has to be told what it is exporting.

(declare (pair (struct (a integer) (b integer)))
         (pair (function pair integer integer)))
(export *pair 'pair)