|
Subject: Re: Another scheme/dsssl question From: Joe English <joe@xxxxxxxxxxxxxxxx> Date: Mon, 29 Dec 1997 15:50:55 PST |
Norm Walsh wrote:
> Is it possible to test for the existance of a definition?
>
> Suppose I want to make it possible for a derived stylesheet to
> override a value. I'd like to write something like this:
>
> (define default-foo '("x" "y" "z"))
> ...
> (if (some-predicate? foo)
> foo
> default-foo)
>
> Is that possible?
No, but according to 8.4 "Definitions",
| [...] A top-level definition of
| a variable in a process specification part is ignored if that variable
| has been defined at the top level in a previous process specification
| part.
So you can simply use
(define default-foo '("x" "y" "z"))
(define foo default-foo)
...
(... foo ...)
in the base stylesheet, and derived stylesheets can
override the default by including (define foo ...) in a
process specification part that precedes the base
stylesheet.
Regarding your earlier question (given a string or symbol "foo",
is there a way to retrieve the value of "foo") -- no, there
is no way to do this in DSSSL or in R4RS Scheme. Common
Lisp has 'eval' and 'symbol-value', which would do what you
want, but these are not present in Scheme. (In fact, it's
not entirely clear what 'eval' and 'symbol-value' should
even _mean_ in the context of Scheme.)
You didn't mention why you wanted this feature, but if
there is a finite, predefined set of symbols that your
stylesheet needs to look up at runtime, you can use
an association list:
(define *symbols*
(list
(cons 'foo foo)
(cons 'bar bar)
...
(cons 'qwerty qwerty)))
(define (symbol-value sym)
(let ((a (assoc sym *symbols*)))
(if a (cadr a) #f)))
(... (symbol-value 'foo) ...)
; or
(... (symbol-value (string->symbol "foo")) ...)
--Joe English
joe@xxxxxxx
DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: Another scheme/dsssl question, Norman Walsh | Thread | Re: Another scheme/dsssl question, Norman Walsh |
| Re: Another scheme/dsssl question, Norman Walsh | Date | Re: Some XSL Questions, DSSSList Owner |
| Month |