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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Scheme help..., Harald Hanche-Olsen | Thread | Re: Scheme help..., Paul Prescod |
Re: conditionaly setting characteri, Chris Maden | Date | Re: Scheme help..., Harald Hanche-Olsen |
Month |