MathGroup Archive 2002

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

Search the Archive

Re: Postponing loading of Package

  • To: mathgroup at
  • Subject: [mg36659] Re: [mg36620] Postponing loading of Package
  • From: Rolf Mertig <rolf at>
  • Date: Wed, 18 Sep 2002 02:09:37 -0400 (EDT)
  • Organization: Mertig Consulting
  • Sender: owner-wri-mathgroup at

yes, this is a comon problem.

You can either do:

y=If[x>1000, ToExpression["BigVariable"][[x]],x] ]

or, maybe more readable, declare at the begging of "ThisPackage":

bigvar := bigvar = ToExpression["OtherPackage`BigVariable"];

and then 

y=If[x>1000, bigvar, x]
(* ************************** *)

Alternatively you can create .mx files which load much quicker than .m files.

It would be really nice if WRI could investigate why loading larger .m files 
is so slow ( I suspect it has to do something with the speed of side effects
like DownValues declarations etc., but I don't know ).

Rolf Mertig
Mertig Consulting

I wrote a package (call it "ThisPackage`") that uses
DeclareePackage["OtherPackage`", {"BigVariable"} ]. The idea was to prevent
the loading of a large file in routine cases. However, when ThisPackage`
defines its functions, inside the Private` area, it includes a conditional
call to BigVariable. It turns out that OtherPackage is loaded when that
function is defined. I was wondering if there is a way to avoid this.
Roughly speaking, here is the setting:

BeginPackage[ "OtherPackage`" ]
BigVariable=Table[x y,{x,1000},{y,1000}]
End[ ]
EndPackage[ ]

BeginPackage[ "ThisPackage`" ]
y=If[x>1000,BigVariable[[x]],x] ]
End[ ]
EndPackage[ ]

I don't want OtherPakage to be loaded unless function[x] is called with
x>1000 but it loads when function is defined. Any ideas?



  • Prev by Date: Re: Postponing loading of Package
  • Next by Date: Re: problems with the definition of a function
  • Previous by thread: Re: Postponing loading of Package
  • Next by thread: LaTeX and Mathematica