scheme/dsssl question

Subject: scheme/dsssl question
From: David Megginson <ak117@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 30 Dec 1997 07:50:19 -0500
Norman Walsh writes:

 > Given that I've got
 > (define foo "this is some text")
 > in my stylesheet, is it possible to write a function that
 > will take "foo" (literally) as an argument and return 
 > "this is some text"?
 > For example:
 > (define (bar xyz) 
 >   ...something I can't quite wrap my head around in here...
 > )
 > such that
 > (bar "foo") returns "this is some text"?

No, there is not.  This would require the use of an 'eval' function
(requiring access to an interpreter), while DSSSL's
parent/sibling/cousin Scheme is designed to be compiled as well as

The key is to use the (assoc ...) function from the expression
language.  First, declare an association list of all the keys and
values that interest you (note the dotted pairs, a hard-core LISP

(define settings
  '(("foo" . "this is some text")
    ("hack" . "this is some more text")))

Next, declare a lookup function:

(define (lookup key)
  (let ((result (assoc key settings)))
    (if result
	(cdr result)

Now, you can use

  (lookup "foo")

with the expected results.

NOTE: Jade does not currently implement the (assoc ..) function, but
here's a scarcely-tested facsimile that you can use as a work-around:

(define (assoc key list)
  (cond ((null? list)
	((equal? (car (car list)) key)
	 (car list))
	 (assoc key (cdr list)))))

Good luck, and all the best,


David Megginson                 ak117@xxxxxxxxxxxxxxxxxxx
Microstar Software Ltd.         dmeggins@xxxxxxxxxxxxx

 DSSSList info and archive:

Current Thread
  • scheme/dsssl question
    • Norman Walsh - from mail1.ability.netby (8.8.5/8.6.12) with ESMTP id NAA24625Mon, 29 Dec 1997 13:09:02 -0500 (EST)
      • Chris Maden - from mail1.ability.netby (8.8.5/8.6.12) with ESMTP id QAA25868Mon, 29 Dec 1997 16:19:19 -0500 (EST)
        • Henry S. Thompson - from mail1.ability.netby (8.8.5/8.6.12) with ESMTP id GAA05269Tue, 30 Dec 1997 06:18:32 -0500 (EST)
          • Chris Maden - from mail1.ability.netby (8.8.5/8.6.12) with ESMTP id KAA07849Tue, 30 Dec 1997 10:24:10 -0500 (EST)
      • <Possible follow-ups>
      • David Megginson - from mail1.ability.netby (8.8.5/8.6.12) with ESMTP id IAA06598Tue, 30 Dec 1997 08:54:20 -0500 (EST) <=