Re: contexts: nailing jelly to a tree?
- To: mathgroup at smc.vnet.net
- Subject: [mg6232] Re: [mg6208] contexts: nailing jelly to a tree?
- From: Allan Hayes <hay at haystack.demon.co.uk>
- Date: Fri, 28 Feb 1997 03:21:59 -0500
- Sender: owner-wri-mathgroup at wolfram.com
murray at math.umass.edu (Murray Eisenberg)
[mg6208] contexts: nailing jelly to a tree?
gives the examples
(* New session #1: *)
BeginPackage["test`"]
Begin["Private`"]
y1 = 99;
Print[Context[y1]]
End[]
EndPackage[]
(* output *)
test`
Private`
Private` (* that's what I expect *)
Private`
(*******************************)
(* New session #2: *)
(* input *)
BeginPackage["test`"];
Begin["Private`"];
y1 = 99;
Print[Context[y1]];
End[];
EndPackage[];
(* output *)
Global` (* this is the surprise *)
(**********************)
Murray:
In #2 The semicolons cause the cell contents to be interpreted as a
single compound expression; all the symbols in this expression are
created before any evaluation; hence all are created in the context
"Global`".
The context "test`" will be added to the context path as before
when the cell is evaluated - you can check this, and the context, by
evaluating {$Context, $ContextPath}
Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk
--
Murray Eisenberg Internet: murray at math.umass.edu
Mathematics & Statistics Dept. Voice: 413-545-2859 (W)
University of Massachusetts 413-549-1020 (H)
Amherst, MA 01003 Fax: 413-545-1801