From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: mark@markwitmer.com Newsgroups: gmane.lisp.guile.user Subject: Re: More Guile 1.8 code failing in 2.x Date: Wed, 27 Feb 2013 08:19:40 -0500 Message-ID: <87mwupao7n.fsf@markwitmer.com> References: <1361959643.2097.179.camel@debian-box.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1361971182 4637 80.91.229.3 (27 Feb 2013 13:19:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Feb 2013 13:19:42 +0000 (UTC) Cc: guile-user@gnu.org To: Richard Shann Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Feb 27 14:20:06 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UAgvV-0002Y9-7Z for guile-user@m.gmane.org; Wed, 27 Feb 2013 14:20:05 +0100 Original-Received: from localhost ([::1]:35015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAgvA-0000Xh-5N for guile-user@m.gmane.org; Wed, 27 Feb 2013 08:19:44 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAgv4-0000T4-3T for guile-user@gnu.org; Wed, 27 Feb 2013 08:19:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAgv2-0003ab-JL for guile-user@gnu.org; Wed, 27 Feb 2013 08:19:38 -0500 Original-Received: from mail-oa0-f46.google.com ([209.85.219.46]:45337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAgv2-0003a6-EE for guile-user@gnu.org; Wed, 27 Feb 2013 08:19:36 -0500 Original-Received: by mail-oa0-f46.google.com with SMTP id k1so1069173oag.19 for ; Wed, 27 Feb 2013 05:19:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type:x-gm-message-state; bh=Ogi8IeQqfc29lpJ3BEsRbpdNRRSVpU3gxw1exJ4JPF0=; b=VPR7b2iCUatplNLXus9vxKEwG5DCpHFw/+CiTX1Z0cV/yj1TE3+rUbxK0FL5FEHULx /+AOpv6AzuvEonh/nnPAw4BRUKMdwqn350pS336xhC+dEF95xAMjyZo4Z8smYlrZvFEJ a4dEFFIWtwP0gjSl4wyINokYglN6xZuttnYmm+Cdn9UuDcYsM4N+RsWkQzLe09vEJ4OG aTGtJ9KyB/XgYqcuzRgzxPMvXOmH3cIhYQkE9Ahwp9gxHi3JiERYmgEgz9ZU89E+yLaN vr6wRpz7i4hVvp2JlxAjFDq1hyqmNvmIn/pAN8etmtwlVct4OOQWwhHApRwrq+Xzr8u3 3tfA== X-Received: by 10.60.6.199 with SMTP id d7mr1920352oea.137.1361971175360; Wed, 27 Feb 2013 05:19:35 -0800 (PST) Original-Received: from localhost (cpe-184-58-115-186.woh.res.rr.com. [184.58.115.186]) by mx.google.com with ESMTPS id w10sm7913759oed.2.2013.02.27.05.19.34 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 27 Feb 2013 05:19:34 -0800 (PST) In-Reply-To: <1361959643.2097.179.camel@debian-box.lan> (Richard Shann's message of "Wed, 27 Feb 2013 10:07:23 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-Gm-Message-State: ALoCoQmND8PeWLdYzzo31MNARORPUS7sRRVao5jW8Xq/Q7EgC46YsH6+zdpSDusGgXow3pTlwtUZ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.219.46 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:10144 Archived-At: Richard Shann 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