Re: Another scheme/dsssl question

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
  • Another scheme/dsssl question
    • Norman Walsh - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id NAA24872Mon, 29 Dec 1997 13:49:04 -0500 (EST)
      • Chris Maden - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id QAA25937Mon, 29 Dec 1997 16:21:38 -0500 (EST)
        • Norman Walsh - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id QAA26170Mon, 29 Dec 1997 16:37:10 -0500 (EST)
        • Joe English - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id SAA26850Mon, 29 Dec 1997 18:53:30 -0500 (EST) <=
          • Norman Walsh - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id JAA07051Tue, 30 Dec 1997 09:04:54 -0500 (EST)