[racket] how can we modify the example from the reference

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Sep 11 20:42:21 EDT 2011


The paragraph in 1.2.3.9 starts with "For a top-level definition (outside of a module), the order of evaluation affects the binding of a generated definition for a generated identifier use." So when you run this example in a top-level environment, e.g., the interactions window (aka repl) it works fine: 

 > (defs-and-usess)
 #t

If you place this example in a definitions window with #lang racket, it is INSIDE a module and signals the error you mention in your message. 

This is indeed a subtle point, and I wish we had no top-level. -- Matthias




On Sep 11, 2011, at 8:18 PM, André Mayers wrote:

> In the section 1.2.3.9 : Macro-Introduced Bindings
> 
> the example below give the following error 
> "define-syntaxes: context (defining "odd.1", ...) expected 2 values,
> received 0 values"
> 
>  (define-syntax defs-and-uses
>     (syntax-rules ()
>       [(def-and-use)
>        (begin
>         ; Declare before definition via no-values define-syntaxes:
>         (define-syntaxes (odd even) (values))
>         (define (odd x) (if (zero? x) #f (even (sub1 x))))
>         (define (even x) (if (zero? x) #t (odd (sub1 x))))
>         (odd 17))]))
> 
> 
> 
> 
> André Mayers, Ph.D., M. Ps.
> professeur agrégé
> Département d'informatique
> Université de Sherbrooke
> Sherbrooke (Québec) Canada J1K 2R1
> tél: +1 819-821-8000 poste 62041
> fax: +1 819-821-8200
> andre.mayers at usherbrooke.ca
> http://info.usherbrooke.ca/AndreMayers
> 
> 
> 
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users




Posted on the users mailing list.