Package dependencies
- To: mathgroup at smc.vnet.net
- Subject: [mg45688] Package dependencies
- From: Maxim <dontsendhere@.>
- Date: Tue, 20 Jan 2004 05:07:59 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Suppose we have a package a.m defining function f: BeginPackage["a`"] f[0] = 0 EndPackage[] Then we create package b.m which introduces additional definitions for f: BeginPackage["b`","a`"] f[1] = f[0] + 1 EndPackage[] Now after loading b.m we'll have f[0]=0 and f[1]=1. Finally, we want to create a package c.m that determines when b.m should be autoloaded. We add the following line to c.m: DeclarePackage["b`","f"] Unfortunately, it doesn't work that way: In[1]:= <<c` f[1] Out[2]= 1+f[0] (standalone kernel will also give f::shdw warning). The reason is that DeclarePackage creates symbol f (with attribute Stub) in the b` context. This implementation decision seems rather questionable: the idea of DeclarePackage is to load b.m when f is first used, which is exactly what we want here -- but nobody said the symbol f was needed in context b`! Probably this difficulty can be avoided by some creative usage of Remove and $NewSymbol, but simply adding Remove["b`f"] to b.m won't solve the problem completely. This is exactly the situation with Geometry\Polytopes.m, Graphics\Polyhedra.m and Graphics\Kernel\init.m -- you can use <<graphics` to declare most of the symbols in all the Graphics\* packages, but not Tetrahedron, Cube and others because there are definitions for them both in Polytopes.m and Polyhedra.m. Maxim Rytin m.r at prontomail.com