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

Re: BOUND?



    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.

Your input specifies a computation without making a distinction bewteen 
program and data.  If the constructor of the list (call it Joe) intended 
that the list be used in such a way, then, as a first approximation at least, 
Joe should quote that which is data:

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

This assumes that Joe knew.  From what you have said, I guess it is possible
that Joe intended that the symbols be the ill-defined maybe-locative-maybe-data
that you have described (no value judgement intended).  More on this 
at your request.

Another possibility is that Joe didn't intend for you to use his list.
In which case, you may be in violation off Joe's abstraction! 
Unpredictable behavior ensues.  Abstraction Police move in to try to 
clean up the wreckage.  Jonathan Rees looks on from the wings, 
shaking his head, with a disgusted look.

You can stop the violation by arranging with Joe to be provided with
the abstraction you need.  So back to what it is I think you need:

I said above that quoting the data was only a first approximation.  
Even better would be for Joe to use procedures, instead of s-expression,
to specify the computation.  For example, Joe might use the
-value- of the expression (LAMBDA () (BAZ:NEW X Y)) instead of 
the list-structure (BAZ:NEW X Y).  Using this approach,  I think it
would be straightforward to to solve you problems in a clear,
safe, and concise way.

If this is not clear, or  you think I have missed the point of your 
question, let me know and I'll try again.

-Norman
-------