MathGroup Archive 1999

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

Search the Archive

Re: calling routine before Needs[]

  • To: mathgroup at
  • Subject: [mg17161] Re: calling routine before Needs[]
  • From: dreiss at ! (David Reiss)
  • Date: Sun, 18 Apr 1999 00:59:45 -0400
  • Organization: EarthLink Network, Inc.
  • References: <7f9fh4$>
  • Sender: owner-wri-mathgroup at

In article <7f9fh4$51o at>, Dan Truong <dtruong at> wrote:

> When a user calls a routine prior to the Needs[] or Get[] then
> he automatically defines the routine.
> However, when the package is loaded afterwards, since the routine
> is already defined, the true routine from the package cannot be
> used (you get a warning though).
> When one writes a package, how can he guarantee that the routines of
> the package will override previous definition?
> I get nowhere with Clear[] or ClearAll[], Remove["Global`*RoutineName"]
> seems
> to work but will generate a warning if the user didn't make any mistake.
> Is there a standard/systematic method to tackle this problem?
> Another point:
> In my package I need global variables to hold informations
> - Is it legal (it seems possible at least) to declare variables in the
> package (ie package variables declared outside the routines of the
> package).
> When a notebook is saved as a package (.m file) it seems everything is
> removed but function declarations.
> - Another solution is to have a routine to build global variables at
> initialization. How can we tell a variable does not exist? Is there a
> routine like ExistQ or DefinedQ[] ?

With regard to the last question, consider using the function Unique:

In[1]:= ?Unique

"Unique[ ] generates a new symbol, whose name is of the form $nnn. Unique[x] 
generates a new symbol, with a name of the form x$nnn. Unique[{x, y, ... }] 
generates a list of new symbols. Unique[\"xxx\"] generates a new symbol, with 
a name of the form xxxnnn."



Scientific Arts:
Creative Services and Consultation 
for the Applied and Pure Sciences

David Reiss 
Email: dreiss at ! 


Remove the !SPAM to send email

  • Prev by Date: Display cannot be used during intialization message
  • Next by Date: Re: Re: BesselJZeros problem/bug?
  • Previous by thread: calling routine before Needs[]
  • Next by thread: Re: calling routine before Needs[]