MathGroup Archive 2003

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

Search the Archive

Re: shadow-proofing a package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42729] Re: shadow-proofing a package
  • From: Bill Rowe <listuser at earthlink.net>
  • Date: Wed, 23 Jul 2003 00:25:21 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 7/22/03 at 4:40 AM, selwynh at earthlink.net (Selwyn Hollis) wrote:

> The following occurred to me as a way to prevent the shadowing problem:
> 
> Before BeginPackage["blah`blahblah`"] put
> 
> Remove@@( StringJoin["Global`",#]&/@
>     Intersection[Names["Global`*"],
>       {"name1", "name2", ... for all symbols defined in the package}] )
> 
> This seems to work well. But surely there must be some downside to it, 
> or else it would already be the recommended way of doing things. What 
> am I overlooking here?

I think what you are overlooking is the potential impact on the user. Suppose one of the symbols this would remove before installing your package contains the results of a lengthy computation already done by the user? I don't see how to differentiate between a symbol intentionally defined by a user and a symbol unintentionally defined by a user trying to invoke a command in your package before actually loading it. 

It seems to me without the ability to determine the user's intent, you have the risk that the implicit assumptions you are making about the user's intent are wrong. And this could cause problems much worse than the one you are trying to avoid.


  • Prev by Date: Re: Evaluation and replacement?
  • Next by Date: Re: Mathematica and RedHat 9
  • Previous by thread: Re: Re: shadow-proofing a package
  • Next by thread: DOUBLE COLUMN TEXT CELL