Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Re: Postponing loading of Package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36652] Re: Postponing loading of Package
  • From: "John Jowett" <John.Jowett at cern.ch>
  • Date: Wed, 18 Sep 2002 02:09:26 -0400 (EDT)
  • Organization: CERN
  • References: <alubet$no8$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hello,
      Dynamic programming might help: replace the line defining BigVariable
with

BigVariable:=BigVariable=Table[x y,{x,1000},{y,1000}]

Then the table will not be calculated unless it is needed.

(See the section on "Functions that Remember Values They Have Found", 2.4.9
in the Mathematica Book).

John Jowett

"ng" <georgakopoulos at mindspring.com> wrote in message
news:alubet$no8$1 at smc.vnet.net...
> I wrote a package (call it "ThisPackage`") that uses
> DeclarePackage["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::usage="example
> Begin[Private`]
> BigVariable=Table[x y,{x,1000},{y,1000}]
> End[ ]
> EndPackage[ ]
>
> BeginPackage[ "ThisPackage`" ]
> function::usage="example
> Begin[Private`]
> function[x_]:=Module[{y},
> 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?
>
>
> Thanks!
>
> Nicholas
>
>
>
>
>




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