Shadow problem of a variable defined in a function context inside different packages
- To: mathgroup at smc.vnet.net
 - Subject: [mg117970] Shadow problem of a variable defined in a function context inside different packages
 - From: Fonseca <public at fonseca.info>
 - Date: Wed, 6 Apr 2011 05:13:36 -0400 (EDT)
 
Hi,
I recovered this peace of code here in the forum (sorry but I no
longer remember it's exact origin), that I use at the end of a
package, to automatically set attributes to all the definitions of the
package.
ToExpression[Names["myPackage`*"], InputForm, Function[x,
SetAttributes[x, {ReadProtected,Locked}], HoldAll]]
The problem with it is that whenever I load two different packages
that were created using this same piece of code, I get a shadowing
message for symbol x.
Can't understand why, since x is in the scope of the function.
I tried to do a Module, but with no success.
I ended up with the following alternative, that works fine:
ToExpression[Names["myPackage`*"], InputForm, SetAttributes[#,
{ReadProtected,Locked}] &]
Nevertheless I was wondering why the first expression doesn't work.
Any clues?
Thank you,
P. Fonseca