MathGroup Archive 2010

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

Search the Archive

Re: SetAttributes for entire package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111366] Re: SetAttributes for entire package
  • From: "Carl K. Woll" <carlw at wolfram.com>
  • Date: Thu, 29 Jul 2010 06:42:47 -0400 (EDT)

On 7/28/2010 1:55 AM, Albert Retey wrote:
> Hi,
>
>    
>> Is there a way to SetAttributes for all of the functions in a package?  I
>> would like them all to be Locked and ReadProtected.
>>      
> you can get a list of all symbol names in your package with:
>
> Names["MyContext`*"]
>
> using SetAttributes on that list should work alright (I haven't tested
> the following but done things like this before):
>
> SetAttributes[ToExpression[Names["MyContext`*"]],{ReadProtected,Locked}]
>
> if you have symbols that have OwnValues defined in your package, you
> might need to delete those from the list of all symbols or need to be
> more careful when creating symbols from the symbol names. You also might
> want to protect the private functions of your package, if there are any...
>
> hth,
>
> albert
>    

An alternative is something like:

ToExpression[Names["MyContext`*"], InputForm,  Function[x, 
SetAttributes[x, {ReadProtected, Locked}], HoldAll]]

so that OwnValues aren't a problem.

Carl Woll
Wolfram Research


  • Prev by Date: Re: TeXForm in 7.0.0
  • Next by Date: Surface integral on a 3D region
  • Previous by thread: Re: SetAttributes for entire package
  • Next by thread: Re: SetAttributes for entire package