unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: mhw@netris.org
To: Jan Nieuwenhuizen <janneke@gnu.org>
Cc: guile-user@gnu.org
Subject: Re: exporting procedure else now breaks case's else clause
Date: Sun, 14 Sep 2014 22:14:42 -0400	[thread overview]
Message-ID: <87d2axy6i5.fsf@netris.org> (raw)
In-Reply-To: <87y4tmilna.fsf@drakenvlieg.flower> (Jan Nieuwenhuizen's message of "Sun, 14 Sep 2014 11:42:01 +0200")

Jan Nieuwenhuizen <janneke@gnu.org> writes:

> Hi,
>
> In stable-2.0, this works
>
>     (define-module (case) #:export (else))
>     (define (else ast) (if (> (length ast) 3) (cadddr ast) #f))
>     (define t 't) (case t ((t) #t) (else (eq? t 't)))
>
> with latest master it breaks as soon as else is added to the exports
> list:
>
>     ;;;
> /home/janneke/vc/verum/development/gaiag/module/gaiag/case.scm:9:31:
> case: invalid clause in subform (else (eq? t (quote t))) of (case t
> ((t) #t) (else (eq? t (quote t))))
>     language/cps/reify-primitives.scm:75:11: In procedure #<procedure
> 2477220 at ice-9/boot-9.scm:509:12 (expr clause clauses)>:
>     language/cps/reify-primitives.scm:75:11: Syntax error:
>     /home/janneke/vc/verum/development/gaiag/module/gaiag/case.scm:9:31:
> case: invalid clause in subform (else (eq? t (quote t))) of (case t
> ((t) #t) (else (eq? t (quote t))))
>
> Bug or feature?

Master's behavior here is correct.  According to both R6RS and R7RS,
syntax literals such as 'else' and '=>' match by comparing bindings
instead of names.  In other words, the binding for 'else' in effect
where the 'case' macro was defined must be the same as the binding for
'else' where you used the case macro, in order for it to match.  R6RS
also allows another way for the syntax literals to match: if 'else' is
unbound in both the definition and usage sites, then it suffices for
them to have the same name.

The intent in modern scheme is that these literals are treated like any
other bindings: 'else' and '=>' are exported from R6RS's (rnrs base) and
R7RS's (scheme base) libraries.  For example, you should be able to
rename these identifiers when you import them, and then use your
alternate names for them instead of the standard names.

For historical reasons, 'else' and '=>' are neither bound nor exported
from Guile's standard libraries, so we rely on the name-based matching
specified by R6RS.

The behavior of Guile 2.0.x is non-standard.  It matches syntax literals
if their names match and either (A) both have the same *non-toplevel*
binding, or (B) neither have a *non-toplevel* binding.  In other words,
in Guile 2.0.x, toplevel bindings are completely ignored for purposes of
matching syntax literals, and the names must match in all cases, so it's
not possible to rename syntax literals within a module.

     Regards,
       Mark



      reply	other threads:[~2014-09-15  2:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-14  9:42 exporting procedure else now breaks case's else clause Jan Nieuwenhuizen
2014-09-15  2:14 ` mhw [this message]

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=87d2axy6i5.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guile-user@gnu.org \
    --cc=janneke@gnu.org \
    /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).