Evaluation of context symbols.
Posted: Mon Nov 07, 2005 8:44 pm
-
When using a function to generate symbols for the creation of contexts the following behavior can be observed:
I find this a little odd since context symbols evaluate to themselves and (build-sym 2) seems to be evaluating to a context the second time it is invoked. But I think the following is really confusing:
So will the real C2 please stand up...? There is only one C2 in the symbol table but there is clearly a different C2 in 'ctx than there is in 'cty. Except:
It is obviously evaluating to a context here. Should not (context? ctx) return true? Or if it is really hiding the function (build-sym) underneath its "symbol" C2 then should not (lambda? ctx) return true? The documentaion is not clear about out how these phantom symbols for contexts (sometimes) need another level of evaluation.
-
When using a function to generate symbols for the creation of contexts the following behavior can be observed:
Code: Select all
> (define (build-sym x) (sym (string 'C x)))
(lambda (x) (sym (string 'C x)))
> (context (build-sym 2))
C2
C2> (context MAIN)
MAIN
> (context? (build-sym 2))
nil
> (context? (eval (build-sym 2)))
true
> (context (build-sym 2))
C2
C2>
Code: Select all
C2> (context MAIN)
MAIN
> (setq ctx (build-sym 2))
C2
> (symbol? ctx)
true
> (context? ctx)
nil
> (setq cty C2)
C2
> (symbol? cty)
nil
> (context? cty)
true
>ctx
C2
>(symbols)
... ? @ C2 MAIN NaN? ...
Code: Select all
> (set ctx "something else")
symbol is protected in function set : C2
> (context ctx)
C2
C2>
-