unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* exporting procedure else now breaks case's else clause
@ 2014-09-14  9:42 Jan Nieuwenhuizen
  2014-09-15  2:14 ` mhw
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Nieuwenhuizen @ 2014-09-14  9:42 UTC (permalink / raw
  To: guile-user

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?

Greetings, Jan

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: exporting procedure else now breaks case's else clause
  2014-09-14  9:42 exporting procedure else now breaks case's else clause Jan Nieuwenhuizen
@ 2014-09-15  2:14 ` mhw
  0 siblings, 0 replies; 2+ messages in thread
From: mhw @ 2014-09-15  2:14 UTC (permalink / raw
  To: Jan Nieuwenhuizen; +Cc: guile-user

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-15  2:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-14  9:42 exporting procedure else now breaks case's else clause Jan Nieuwenhuizen
2014-09-15  2:14 ` mhw

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).