question about context chapter in manual

Started by csfreebird, November 19, 2013, 07:34:24 AM

Previous topic - Next topic

csfreebird

Hi, Lutz:

  When reading this:
QuoteWhen a user-defined function is evaluated, the context is switched to the parent context of the symbol it is called with.


Does the symbol(red color above) mean user-defined function here?

If there are context A  and B, B has a user-defined function myfun

in A context, I write code to call myfun of B context, and what will happen?



word "parent context" only occures once in your manual, I do not know what dows it mean.

caller's context?

Lutz

#1
Should say better: "When s user-defined function is evaluated, the context is switched to the name-space which owns the that symbol."



(context 'Foo)

(define (my-func)
    (println "context is now: " (context)))

(context MAIN)

Now when calling Foo:my-func from anywhere else, the context will switch to Foo.

> (Foo:my-func)
context is now: Foo
Foo
>