Re: define-library-alias Marc Nieper-Wißkirchen 22 Sep 2020 16:12 UTC

Am Di., 22. Sept. 2020 um 18:05 Uhr schrieb Lassi Kortela <xxxxxx@lassi.io>:
>
> >>   (define-library (scheme list)
> >>     (extends (srfi 1))
> >
> > I think there is a fundamental difference between `(alias-for (srfi
> > 1))` and `(extends (srfi 1))`. In the former case, we just have one
> > library with two names. In particular, the library only has to be
> > loaded (and expanded) once. In the latter case, we have to libraries
> > (which just may happen to be equivalent) that have to be loaded and
> > expanded separately. So it even makes sense to have both forms
> > separately. The `extends` form would expand into an import declaration
> > together with a corresponding export declaration. It makes sense to
> > allow that the `extends` form is decorated with `only`, `prefix`,
> > `rename`, and `except`.
>
> There doesn't have to be a fundamental difference if
>
> (define-library (foo) (alias-for (bar)))
>
> is parsed magically as something different from an ordinary
> `define-library`.

I meant that there is a fundamental difference between a mere library
alias and a library defined through a hypothetical "extend" library
declaration:

(define-library (srfi 158)
  (extend (srfi 121))
  (export make-accumulator ...)
  (import (scheme base) ...)
  (begin ...))

The top-level library environment of an aliased library will be
shared, while the top-level library environment of a library extending
another one will be a new one. This can be observed through
hygiene-bending given a sufficiently powerful macro system.

> But I agree that `define-library-alias` is more elegant.
>
> The symmetry with Chez Scheme `alias` (which you refer to in your
> pre-SRFI <https://github.com/mnieper/srfi-212>) is nice.

Already implemented in Unsyntax. :) Basically just two lines of
non-trivial code.