unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: "Andy Wingo" <wingo@pobox.com>
Cc: guile-devel@gnu.org
Subject: Re: Document top-level pseudo-hygiene
Date: Sun, 26 Jan 2014 23:50:34 -0500	[thread overview]
Message-ID: <87r47ugh9h.fsf@netris.org> (raw)
In-Reply-To: <E1W7QOI-0001rc-JS@vcs.savannah.gnu.org> (Andy Wingo's message of "Sun, 26 Jan 2014 14:08:50 +0000")

Hi Andy,

"Andy Wingo" <wingo@pobox.com> writes:
> commit 03dfed840b377a72191b6f125c106fdfd9e90a21
> Author: Andy Wingo <wingo@pobox.com>
> Date:   Fri Jan 24 12:34:26 2014 +0100
>
>     Document top-level pseudo-hygiene
>     
>     * doc/ref/api-macros.texi (Hygiene and the Top-Level): Add a section
>       documenting our pseudo-hygienic top-level names.

As I've said before, I strenuously object to these novel semantics that
you've invented.  I believe this would be an ugly wart on Guile that we
would have to support indefinitely, in violation of the standards,
because its existence would encourage people to write code that depends
upon it.

> +If introduced top-level identifiers ``escape'' a module, in whatever
> +way, they then form part of the binary interface (ABI) of a module.  It
> +is unacceptable from an engineering point of view to allow the ABI to
> +change randomly.  (It also poses practical problems in meeting the
> +recompilation conditions of the Lesser GPL license, for such modules.)

I understand the problem you are trying to solve.  Please allow me to
make a counter-proposal:

> +For this reason many people prefer to never use identifier-introducing
> +macros at the top-level, instead making those macros receive the names
> +for their introduced identifiers as part of their arguments, or to
> +construct them programmatically and use @code{datum->syntax}.

Yes, this is exactly what we must teach people to do when an introduced
toplevel identifier would cross a module boundary.  It is the only way
to completely solve the ABI problem.

Your proposal not only violates the standards, but also fails to solve
the ABI problem adequately.  The problem is that if a library author
needs to change any of the macro uses in their library, then the
toplevel identifiers introduced by these macro uses will also change,
and thus break the ABI.

To make this more concrete, consider the example you used in the docs:

  (define-syntax-rule (defconst name val)
    (begin
      (define t val)
      (define-syntax-rule (name) t)))

Now suppose that a library contains the following macro use:

  (defconst supported-srfis '(1 4 13 14 16 23 30 39 46))

Your proposed solution means that the library author cannot add to this
list without unintentionally breaking their ABI.  This is a mistake that
an author might easily make, and your proposal not only does nothing to
solve it, but encourages authors to write code that will lead to this
mistake.

In this case, what the library author really needs is for 't' to have a
name derived from 'name', but ignoring 'val'.  Of course, there's no way
for Guile to read the author's mind.  The author must make this decision
explicitly.

Now, to reduce the danger that a library author might unwittingly make
the mistake you're (rightly) worried about, I suggest that we rig the
compiler to issue a warning whenever an introduced toplevel identifier
crosses a module boundary.

What do you think?

      Mark



       reply	other threads:[~2014-01-27  4:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1W7QOI-0001rc-JS@vcs.savannah.gnu.org>
2014-01-27  4:50 ` Mark H Weaver [this message]
2014-02-06 23:13   ` Document top-level pseudo-hygiene Ludovic Courtès
2014-03-25 20:07   ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r47ugh9h.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guile-devel@gnu.org \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).