Re: scheme/dsssl question

Subject: Re: scheme/dsssl question
From: Chris Maden <crism@xxxxxxx>
Date: Tue, 30 Dec 1997 10:28:07 -0500
[Henry Thompson]
> The normal strategy to get around this feature is to use thunks,
> i.e. procedural closures of no arguments:
> 
> (define (dblappl fn thunk) (fn (thunk) (thunk)))
> 
> (let ((foo 3)) (dblappl + (lambda () foo)))
> 
> The thunk of necessity carries its lexical environment with it,
> achieving the encapsulation you need.
> 
> Hope this helps

I don't think this helps with Norm's question, where a string or
symbol is passed as an argument to a function which then finds the
value of the object defined with that name.

(define foo
  3)

(define bar
  ... )

such that (bar 'foo) will return 3 or some function thereof.  Would
thunks work here?

(define (bar thunk)
  (thunk))

or better yet,

(define (bar thunk)
  (if (string? thunk)
    ((string->symbol thunk))
    (thunk)))

-Chris
-- 
<!NOTATION SGML.Geek PUBLIC "-//Anonymous//NOTATION SGML Geek//EN">
<!ENTITY crism PUBLIC "-//O'Reilly//NONSGML Christopher R. Maden//EN"
"<URL>http://www.oreilly.com/people/staff/crism/ <TEL>+1.617.499.7487
<USMAIL>90 Sherman Street, Cambridge, MA 02140 USA" NDATA SGML.Geek>


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread
  • scheme/dsssl question
    • Norman Walsh - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id NAA24625Mon, 29 Dec 1997 13:09:02 -0500 (EST)
      • Chris Maden - from mail1.ability.netby web4.ability.net (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 web4.ability.net (8.8.5/8.6.12) with ESMTP id GAA05269Tue, 30 Dec 1997 06:18:32 -0500 (EST)
          • Chris Maden - from mail1.ability.netby web4.ability.net (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 web4.ability.net (8.8.5/8.6.12) with ESMTP id IAA06598Tue, 30 Dec 1997 08:54:20 -0500 (EST)