[gambit-list] How to use define-syntax and cond-expand in one program?

Marc Feeley feeley at iro.umontreal.ca
Fri Jun 29 13:05:01 EDT 2012


The cond-expand macro is defined both in the Gambit runtime and in the syntax-case expander.  The native Gambit version accesses the cond-expand feature list, but the syntax-case version does not (because it is implemented with syntax-rules, which can't execute code which accesses the cond-expand feature list).

The solution would be to rewrite the syntax-case version of cond-expand using the syntax-case form.  If you are interested in doing this, the code is in lib/psyntax73.ss .  You'll also need a syntax-case version of define-cond-expand-feature to avoid phasing problems.

Marc

On 2012-06-29, at 10:51 AM, Sven Hartrumpf wrote:

> Hi.
> 
> Fri, 29 Jun 2012 10:28:45 -0400, feeley wrote:
>> Can you give more details on the nature of the error.
> 
> Sure. Here is a small (mostly) minimal example:
> 
>> cat top.scm
> (include "srfi1.scm")
> (define-cond-expand-feature srfi-1)
> (include "part.scm")
> (write (first '(a)))
> 
>> cat srfi1.scm
> (define (first l) (car l))
> 
>> cat part.scm
> (cond-expand
> ((not srfi-1)
>  (define (first l) (car l)))
> (else))
> 
>> gsc -:s top.scm
> top.c: In function '___H__20_top_2e_o2':
> top.c:178:1: error: duplicate label '___L0_first'
> top.c:141:1: note: previous definition of '___L0_first' was here
> top.c:181:1: error: duplicate label '___L_first'
> top.c:144:1: note: previous definition of '___L_first' was here
> top.c:188:1: error: duplicate label '___L2_first'
> top.c:151:1: note: previous definition of '___L2_first' was here
> top.c:190:1: error: duplicate label '___L1_first'
> top.c:153:1: note: previous definition of '___L1_first' was here
> top.c:192:1: error: duplicate label '___L3_first'
> top.c:155:1: note: previous definition of '___L3_first' was here
> 
> Ciao
> Sven
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list




More information about the Gambit-list mailing list