* problems evaluating code depending on version
@ 2012-05-16 21:32 Stefan Israelsson Tampe
2012-05-17 8:20 ` Andy Wingo
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Israelsson Tampe @ 2012-05-16 21:32 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 798 bytes --]
hi,
I'm trying to use this as a way to defined different versions of the code
depending on the
guile-version. So here it is,
(eval-when (compile load eval)
(define (ver)
(let ((v (version)))
(cond
((string-match "^2.0" v)
'v2.0)
((string-match "^2.1" v)
'v2.1)
(else #f)))))
(define-syntax guile-stuff
(lambda (x)
(syntax-case x ()
(_
(let ((q (ver)))
(cond
((eq? q 'v2.0)
#'(begin 1))
((eq? q 'v2.1)
#'(begin
(define-syntax-rule (fluid-let-syntax . l)
(syntax-parametrize . l))
(export fluid-let-syntax)))
(else (error "not supported version"))))))))
(guile-stuff)
This does not work in master (v2.1) why?
/Stefan
[-- Attachment #2: Type: text/html, Size: 979 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: problems evaluating code depending on version
2012-05-16 21:32 problems evaluating code depending on version Stefan Israelsson Tampe
@ 2012-05-17 8:20 ` Andy Wingo
2012-05-17 12:47 ` Stefan Israelsson Tampe
0 siblings, 1 reply; 5+ messages in thread
From: Andy Wingo @ 2012-05-17 8:20 UTC (permalink / raw)
To: Stefan Israelsson Tampe; +Cc: guile-devel
On Wed 16 May 2012 23:32, Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:
> (define-syntax guile-stuff
> (lambda (x)
> (syntax-case x ()
> (_
> (let ((q (ver)))
> (cond
> ((eq? q 'v2.0)
> #'(begin 1))
> ((eq? q 'v2.1)
> #'(begin
> (define-syntax-rule (fluid-let-syntax . l)
> (syntax-parametrize . l))
> (export fluid-let-syntax)))
> (else (error "not supported version"))))))))
Here the macro introduces a new identifier, fluid-let-syntax. But its
context is not that of the (guile-stuff) expression. If you did
(datum->syntax 'fluid-let-syntax x) that might work.
In general cond-expand is better. I just added a guile-2.2 feature on
master. Use that instead.
But in this case, better to just change both versions to use
syntax-parameterize :)
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: problems evaluating code depending on version
2012-05-17 8:20 ` Andy Wingo
@ 2012-05-17 12:47 ` Stefan Israelsson Tampe
2012-05-17 13:25 ` Andy Wingo
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Israelsson Tampe @ 2012-05-17 12:47 UTC (permalink / raw)
To: Andy Wingo; +Cc: guile-devel
[-- Attachment #1: Type: text/plain, Size: 1364 bytes --]
I tried cond-expand, just to see if it worked and no
the export clause does not fall through and the symbols are not exported.
I can fix this as you say by using the new interface syntax-parameter
interface
but I'm curious how to be ably to conditionally export symbols depending on
the
guile-version!
/Stefan
On Thu, May 17, 2012 at 10:20 AM, Andy Wingo <wingo@pobox.com> wrote:
> On Wed 16 May 2012 23:32, Stefan Israelsson Tampe <stefan.itampe@gmail.com>
> writes:
>
> > (define-syntax guile-stuff
> > (lambda (x)
> > (syntax-case x ()
> > (_
> > (let ((q (ver)))
> > (cond
> > ((eq? q 'v2.0)
> > #'(begin 1))
> > ((eq? q 'v2.1)
> > #'(begin
> > (define-syntax-rule (fluid-let-syntax . l)
> > (syntax-parametrize . l))
> > (export fluid-let-syntax)))
> > (else (error "not supported version"))))))))
>
> Here the macro introduces a new identifier, fluid-let-syntax. But its
> context is not that of the (guile-stuff) expression. If you did
> (datum->syntax 'fluid-let-syntax x) that might work.
>
> In general cond-expand is better. I just added a guile-2.2 feature on
> master. Use that instead.
>
> But in this case, better to just change both versions to use
> syntax-parameterize :)
>
> Andy
> --
> http://wingolog.org/
>
[-- Attachment #2: Type: text/html, Size: 1982 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: problems evaluating code depending on version
2012-05-17 12:47 ` Stefan Israelsson Tampe
@ 2012-05-17 13:25 ` Andy Wingo
2012-05-17 14:18 ` Stefan Israelsson Tampe
0 siblings, 1 reply; 5+ messages in thread
From: Andy Wingo @ 2012-05-17 13:25 UTC (permalink / raw)
To: Stefan Israelsson Tampe; +Cc: guile-devel
On Thu 17 May 2012 14:47, Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:
> I tried cond-expand, just to see if it worked and no
> the export clause does not fall through and the symbols are not exported.
>
> I can fix this as you say by using the new interface syntax-parameter interface
> but I'm curious how to be ably to conditionally export symbols depending on the
> guile-version!
(cond-expand
(not guile-2.2
(define-syntax-rule (fluid-let-syntax . l)
(syntax-parameterize . l)))
(else #t))
At the top level, not wrapped in (guile-stuff) :)
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: problems evaluating code depending on version
2012-05-17 13:25 ` Andy Wingo
@ 2012-05-17 14:18 ` Stefan Israelsson Tampe
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Israelsson Tampe @ 2012-05-17 14:18 UTC (permalink / raw)
To: Andy Wingo; +Cc: guile-devel
[-- Attachment #1: Type: text/plain, Size: 984 bytes --]
Your version works but I would like to export as well in the cond-expand
e.g.
(cond-expand
(guile-2.2
(define-syntax-rule (fluid-let-syntax . l)
(syntax-parametrize . l))
(export fluid-let-syntax))
(guile-2)
(else (error "not supported version")))
/Stefan
On Thu, May 17, 2012 at 3:25 PM, Andy Wingo <wingo@pobox.com> wrote:
> On Thu 17 May 2012 14:47, Stefan Israelsson Tampe <stefan.itampe@gmail.com>
> writes:
>
> > I tried cond-expand, just to see if it worked and no
> > the export clause does not fall through and the symbols are not exported.
> >
> > I can fix this as you say by using the new interface syntax-parameter
> interface
> > but I'm curious how to be ably to conditionally export symbols depending
> on the
> > guile-version!
>
> (cond-expand
> (not guile-2.2
> (define-syntax-rule (fluid-let-syntax . l)
> (syntax-parameterize . l)))
> (else #t))
>
> At the top level, not wrapped in (guile-stuff) :)
>
> Andy
> --
> http://wingolog.org/
>
[-- Attachment #2: Type: text/html, Size: 1538 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-05-17 14:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-16 21:32 problems evaluating code depending on version Stefan Israelsson Tampe
2012-05-17 8:20 ` Andy Wingo
2012-05-17 12:47 ` Stefan Israelsson Tampe
2012-05-17 13:25 ` Andy Wingo
2012-05-17 14:18 ` Stefan Israelsson Tampe
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).