From: mark@markwitmer.com
To: Richard Shann <richard.shann@virgin.net>
Cc: guile-user@gnu.org
Subject: Re: More Guile 1.8 code failing in 2.x
Date: Wed, 27 Feb 2013 08:19:40 -0500 [thread overview]
Message-ID: <87mwupao7n.fsf@markwitmer.com> (raw)
In-Reply-To: <1361959643.2097.179.camel@debian-box.lan> (Richard Shann's message of "Wed, 27 Feb 2013 10:07:23 +0000")
Richard Shann <richard.shann@virgin.net> writes:
> We have one more construct being refused as we upgrade to guile 2.0 in
> GNU/Denemo
>
> (if (not (defined? 'ToggleTripleting::InsideTriplet))
> (define ToggleTripleting::InsideTriplet #t))
>
> It is intended to set up a flag which toggles between true and false on
> each call. If already set up, the flag is not altered.
>
> Apparently (I haven't been able to check) Guile 2.0 gives an error.
>
> #f definition in expression context, where definitions are not
> allowed, ((line . 2) (column . 4) (filename . #f)) (define
> ToggleTripleting::InsideTriplet #t) #f)
>
> Can anyone suggest what could replace that? I would prefer to to replace
> it with something that has the same semantics, rather than setting up
> some alternative method of handling the situation - registering all such
> variables on program startup, or some such - as at the moment this code
> only evaluated if used and doesn't require any mechanism to get
> initialized, other than this construct.
>
> Richard Shann
>
>
>
>
Hi Richard,
You can probably just replace your code with
(define-once ToggleTripleting::InsideTriplet #t)
(define-once ...) works like defvar in Common Lisp and will not
redefine a variable once it has been defined. You can read about it at
the bottom of the node "Top Level Variable Definitions" in the Guile
manual.
I'm still learning the ins and outs of procedural macros, but I think
that if you need to include (define ...) in a conditional like that for
more complicated purposes, you can use syntax-case like this:
(define-syntax conditional-define
(lambda (x)
(syntax-case x ()
((conditional-define arg val)
(let ((arg-datum (syntax->datum #'arg)))
(if (not (defined? arg-datum))
#'(define arg val)
#'*unspecified*))))))
--
Mark Witmer
next prev parent reply other threads:[~2013-02-27 13:19 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 [this message]
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
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=87mwupao7n.fsf@markwitmer.com \
--to=mark@markwitmer.com \
--cc=guile-user@gnu.org \
--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).