question about context chapter in manual

Q&A's, tips, howto's
Locked
csfreebird
Posts: 107
Joined: Tue Jan 15, 2013 11:54 am
Location: China, Beijing
Contact:

question about context chapter in manual

Post by csfreebird »

Hi, Lutz:
When reading this:
When 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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: question about context chapter in manual

Post by Lutz »

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

Code: Select all

(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.

Code: Select all

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

Locked