Re: Format of S-expression metadata for SRFI documents
Ciprian Dorin Craciun 13 Mar 2019 15:27 UTC
On Tue, Mar 12, 2019 at 7:15 PM Lassi Kortela <xxxxxx@lassi.io> wrote:
> Ciprian's version separates all combinations of required and optional
> arguments so that each combination is a separate arglist. Because there
> can be interdependencies between arguments. E.g.:
>
> (make-vector
> (type constructor)
> (export scheme:base)
> (signature
> ((range-length-zero) -> vector-empty)
> ((range-length-zero any) -> vector-empty)
> ((range-length-not-zero) -> vector-not-empty)
> ((range-length-not-zero any) -> vector-not-empty)))
As said this was a choice of style. Nothing stops one to just say
`(signature ((range-length) -> vector))`.
In fact the "signature" part has the Erlang semantic:
* given a set of concrete arguments, (i.e. their number and types are known)
* iterate top-to-bottom through all the "signature" variants, and
* the first variant which matches the concrete arguments (i.e. they
are of the same type, and possibly taking into account optional and
rest variants),
* is the one that should be considered for those concrete arguments;
(I think this resembles more the `cond` or `case-lambda` style.)
> That doesn't have arg names but they can be added next to the types.
The underlying tool does support argument names. (I'll try to come-up
with an example that takes everything into account.)
> Ciprian, what's your current feeling about what the best place would be
> to store your type signatures? Would you like to have them in the same
> metadata file or a different one?
I think separate files is easier to integrate various tools and workflows.
> Also, would the type signatures affect syntax definitions, or would
> those be done in traditional Lisp style?
Syntaxes (i.e. "macros") have a different "signature" syntax, one very
similar to the actual `syntax-rules` syntax.
For example (from simple to complex ones) the following are the HTML rendering:
* https://vonuvoli.volution.ro/documentation/libraries-html/r7rs/definitions/if.html#definition__r7rs__if
* https://vonuvoli.volution.ro/documentation/libraries-html/r7rs/definitions/define.html#definition__r7rs__define
* https://vonuvoli.volution.ro/documentation/libraries-html/r7rs/definitions/let.html#definition__r7rs__let
* https://vonuvoli.volution.ro/documentation/libraries-html/r7rs/definitions/do.html#definition__r7rs__do
* https://vonuvoli.volution.ro/documentation/libraries-html/r7rs/definitions/define-record-type.html#definition__r7rs__define-record-type
And their S-expression based definitions:
* https://github.com/volution/vonuvoli-scheme/blob/development/documentation/libraries-r7rs.ss#L2811
* https://github.com/volution/vonuvoli-scheme/blob/development/documentation/libraries-r7rs.ss#L1967
* https://github.com/volution/vonuvoli-scheme/blob/development/documentation/libraries-r7rs.ss#L2053
* https://github.com/volution/vonuvoli-scheme/blob/development/documentation/libraries-r7rs.ss#L2551
* https://github.com/volution/vonuvoli-scheme/blob/development/documentation/libraries-r7rs.ss#L3102
Ciprian.