MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Making new Contexts in Modules in a package

  • To: mathgroup at
  • Subject: [mg48376] Re: Making new Contexts in Modules in a package
  • From: Jens-Peer Kuska <kuska at>
  • Date: Wed, 26 May 2004 02:41:28 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <c8vcv5$alu$>
  • Reply-to: kuska at
  • Sender: owner-wri-mathgroup at


a) you can't have a function with name Function[] because
   Function[] is used by Mathematica for pure functions
b) you should not create contexts for file names because
   file names can have . \ of / characters in it and this is
   not allowed in a context
c) you must build a symbol in the context you wish with


Johan van der Meer wrote:
> Hello, I am fairly new to mathematica and need some help with this
> context stuff :-).
> What I want is to read with a function in a package some data (from a
> file), and put that in a (nested) list called listname`unmodifiedlist.
> The idea is to make modifications to that list with other functions,
> where the new list name is listname`modifiedlist.
> So what I want is a function called MakeList[data_String], that reads
> the data and puts it in the variable unmodifiedlist in the (newly made)
> context data.
> Then, in my notebook I can simply type:
> MakeList["data"]
> Plot[data`unmodifiedlist]
> to plot it for example.
> I have in a package (package.m) a function that looks like this:
> Function[data_String]:=
> Module[{newcontext="",unmodifiedlist,readlist},
> unmodifiedlist=ReadList[OpenRead[data],Number];
> Close[data];
> newcontext=ToString[context]<>"`";
> $ContextPath=Join[$ContextPath,{newcontext}];
> $Context=newcontext;
> unmodifiedlist=readlist;
> ]
> However, this doesn't seem to work. What I also tried is to change the
> context in the beginning of my module to "data`". I am not sure if this
> is good programming either, or if I should be wanting this with
> mathematica, but any help is greatly appreciated.
> Regards,
> Johan van der Meer

  • Prev by Date: Re: Problem with function
  • Next by Date: Re: WTD: point intersection in space
  • Previous by thread: Making new Contexts in Modules in a package
  • Next by thread: ANFIS