[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BOUND?



I recently had occasion to use a really hairy construct, which looked
like the following:

    ((*value *t-implementation-env* '*bound?)
     (repl-env)
     (car x) )

I couldn't see any easy way around this; not even BOUND? helped, and I know
that's supposed to be taboo too.  This is what I was trying to do.  I had a
list (that belonged to someone else) which looked like this:

    (foo:new a b (baz:new x y) (c d) e)

and I had to evaluate this to give a structure of type FOO, with components

    A
    B
    a structure of type BAZ with components X, Y
    (C D)
    E

In other words, I knew not whether the elements of the given list, viz.,
A, B, (BAZ:NEW X Y), (C D) and E, were data elements, or functions to be
recursively evaluated.  The atoms were supposed to go through as they were.
(BAZ:NEW X Y) was supposed to be evaluated, since BAZ:NEW was a structure
constructor, but (C D) was supposed to be unevaluated since C was not a
procedure or an operation.

I therefore MAPped a variable X down this list.  I allowed atoms to go
through, but I needed to test the CARs of pairs for PROCEDUREhood or even
BOUND?ness.  (BOUND? (CAR X)) obviously wouldn't work since BOUND? is a
special form and doesn't evaluate the (CAR X), and so I had to resort to
the above construct.  The overall conjunct that I tested looked like:

    (and (pair? x) 
         ((*value *t-implementation-env* '*bound?)
          (repl-env)
          (car x) )
         (procedure? (eval (car x) *scratch-env*)))

If this looks as horrible to you as it does to me, you know why I'm posting
this note!  This is supposed to both evoke suggestions on how better to do
the task as well as demonstrate a need for BOUND? (cf. earlier discussion).

Ashwin Ram.


-------