Re: Scheme help...

Subject: Re: Scheme help...
From: Daniel Speck <dspeck@xxxxxxxxxxxx>
Date: Tue, 24 Feb 1998 13:37:30 -0500
Norman Walsh wrote:

> It's clear from the way that they behave that
>
> (define %gentext-by%
>   (case ($lang$)
>     <![%l10n-usen[ (("usen") %gentext-usen-by%) ]]>
>     <![%l10n-dege[ (("dege") %gentext-dege-by%) ]]>
>     <![%l10n-ru[ (("ru")     %gentext-ru-by%) ]]>
>     (else "L10N ERROR: %gentext-by%")))
>
> is different from
>
> (define (%gentext-by%)
>   (case ($lang$)
>     <![%l10n-usen[ (("usen") %gentext-usen-by%) ]]>
>     <![%l10n-dege[ (("dege") %gentext-dege-by%) ]]>
>     <![%l10n-ru[ (("ru")     %gentext-ru-by%) ]]>
>     (else "L10N ERROR: %gentext-by%")))

> In particular (current-node) can be accessed in $lang$ if I use
> the latter (literal (%gentext-by%)), but not if I use the former
> (literal %gentext-by%).
>
> Can someone satisfy my intellectual curiosity and explain the
> difference?  In particular, why "current-node doesn't exist" in
> the former.
>

Yes, the former defines the value of the variable %gentext-by% to be the
value of the specified (case ...) expression. It is evaluated before the
(root ...) or any (element ...) rules have fired and thus, cannot refer to
(current-node) because there isn't one.

The latter defines the value of the variable %gentext-by% to be a
0-argument function the body of which is the same (case ...) expression. It
differs from the first in that the body is only evaluated when the function
is actually called. Note that you can still cause an error if, say, you try
something like:

(define foo (%gentext-by%))

because (current-node) will not be defined until you are inside some
(element ...) rule.

-dan

--
Daniel Speck                              e-mail: dspeck@xxxxxxxxxxxx
Research Engineer                          voice:     +1 301.548.7818
Thomson Technology Services Group            fax:     +1 301.527.4094
1375 Piccard Drive, Rockville, MD 20850      WWW:    www.thomtech.com

begin:          vcard
fn:             Daniel Speck
n:              Speck;Daniel
org:            Thomson Technology Services Group
adr:            1375 Piccard Drive;;Suite 250;Rockville;MD;20850;USA
email;internet: dspeck@xxxxxxxxxxxx
title:          Research Engineer
tel;work:       (301) 548-7818
tel;fax:        (301) 527-4094
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard

Current Thread
  • Scheme help...
    • Norman Walsh - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id MAA11150Tue, 24 Feb 1998 12:38:36 -0500 (EST)
      • Chris Maden - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id NAA11905Tue, 24 Feb 1998 13:25:56 -0500 (EST)
        • Harald Hanche-Olsen - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id NAA12831Tue, 24 Feb 1998 13:55:43 -0500 (EST)
      • Daniel Speck - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id NAA12415Tue, 24 Feb 1998 13:40:36 -0500 (EST) <=
      • Paul Prescod - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id PAA14183Tue, 24 Feb 1998 15:30:40 -0500 (EST)
        • Earl Hood - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id QAA14800Tue, 24 Feb 1998 16:06:14 -0500 (EST)
          • Kendall G. Clark - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id RAA15832Tue, 24 Feb 1998 17:23:58 -0500 (EST)
          • Norman Walsh - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id RAA16128Tue, 24 Feb 1998 17:39:30 -0500 (EST)