From: Andy Wingo <wingo@pobox.com>
To: Richard Shann <richard.shann@virgin.net>
Cc: mark@markwitmer.com, guile-user@gnu.org
Subject: Re: More Guile 1.8 code failing in 2.x
Date: Wed, 27 Feb 2013 16:08:49 +0100 [thread overview]
Message-ID: <87zjypu73y.fsf@pobox.com> (raw)
In-Reply-To: <1361974971.2097.194.camel@debian-box.lan> (Richard Shann's message of "Wed, 27 Feb 2013 14:22:51 +0000")
Hi Richard,
On Wed 27 Feb 2013 15:22, Richard Shann <richard.shann@virgin.net> writes:
> On Wed, 2013-02-27 at 08:19 -0500, mark@markwitmer.com wrote:
>> Richard Shann <richard.shann@virgin.net> writes:
>>
>> > (if (not (defined? 'ToggleTripleting::InsideTriplet))
>> > (define ToggleTripleting::InsideTriplet #t))
I'm sorry we were not able to make this case work in Guile 2; it's quite
complicated actually.
>> You can probably just replace your code with
>>
>> (define-once ToggleTripleting::InsideTriplet #t)
>
> Thanks for this - it seems define-once is not defined in guile 1.8
> however
You could define it in a prelude somewhere:
(cond-expand
(guile-2) ; nothing
(else ; guile < 2.0
(define-macro (define-once sym exp)
`(if (not (defined? ',sym)) (define ,sym ,exp)))))
Then you could change all uses of this idiom to use define-once.
Note that Guile 2.'s `define-once' is slightly different; it always
declares a local definition, and it uses the existing value only if
there is already a local definition. In this way imported values get
overridden by define-once.
Here is a Guile 2-compatible version:
(cond-expand
(guile-2) ; nothing
(else ; guile < 2.0
(define-macro (define-once sym exp)
`(define ,sym (if (module-locally-bound? ',sym) ,sym ,val)))))
Finally in Guile 2 there is also the `define!' procedure, which makes
top-level definitions programmatically. Use it if you need it. But if
you can, better to rewrite to use standard Scheme.
In general I recommend adding shims to Denemo to make it
forward-compatible -- like adding define-once if needed so that it uses
the Guile 2.0 idioms, even on 1.8.
Good luck, and let us know how it goes.
Andy
--
http://wingolog.org/
next prev parent reply other threads:[~2013-02-27 15:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-27 10:07 More Guile 1.8 code failing in 2.x Richard Shann
2013-02-27 13:19 ` mark
2013-02-27 14:22 ` Richard Shann
2013-02-27 14:28 ` Ludovic Courtès
2013-02-27 14:48 ` Mike Gran
2013-02-27 17:54 ` Richard Shann
2013-02-27 15:08 ` Andy Wingo [this message]
2013-02-27 15:13 ` Andy Wingo
2013-02-27 17:59 ` Richard Shann
2013-02-27 14:50 ` Stefan Israelsson Tampe
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=87zjypu73y.fsf@pobox.com \
--to=wingo@pobox.com \
--cc=guile-user@gnu.org \
--cc=mark@markwitmer.com \
--cc=richard.shann@virgin.net \
/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).