Re: using functions with package name prefixed.
- To: mathgroup at smc.vnet.net
- Subject: [mg45656] Re: using functions with package name prefixed.
- From: "Peltio" <peltio at twilight.zone>
- Date: Fri, 16 Jan 2004 19:58:39 -0500 (EST)
- References: <email@example.com>
- Reply-to: "Peltio" <peltioNOSP at Miname.com.invalid>
- Sender: owner-wri-mathgroup at wolfram.com
"steve_H" wrote >In Java for instance, I can write Boo.foo(), which makes it more >clear where foo() is located. > >Is there a way to do something like this in Mathematica? I guess there is. Perhaps by changing BeginPackage["boo`"] and EndPackage into Begin["boo`"] and End will avoid the actual context specified in Begin to be loaded into the list of available contexts. Begin["Boo`"] Boo` foo=12345; End Boo` foo foo Boo`foo 12345 So a (rather explosive) file named Boo.m containing ______________________ Begin["Boo`"] foo=12345; End ______________________ and loaded with Get <<Boo.m should do what you want, I guess. >and is there a way >to only load the function that I need from the package without loading >everything? I don't think so. Mathematica reads all package contents in one single gulp, AFAIK. You can define a 'package' for each single function and load them one at the time. I guess it is possibile to define 'stubs' to do that with packages. Perhaps it's possibile to extend this method even to files thas use Begin instead of BeginPackage. Or, better yet, maybe using ordinary packages and then removing their contexts just after they have been loaded, could solve your problems. Have a look at the documentation for Contexts, Begin, BeginPackage and DeclarePackage. I am sorry I can't help you more right now (time is a harsh master : )) ), but I hope these hints can be of some help, anyway. cheers, Peltio -- Invalid address in reply-to. Crafty demunging required to mail me.