Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1502
| From | Fonseca <public@fonseca.info> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Shadow problem of a variable defined in a function context inside different packages |
| Date | 2011-04-06 09:14 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <inhat3$2b1$1@smc.vnet.net> (permalink) |
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
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Shadow problem of a variable defined in a function context inside different packages Fonseca <public@fonseca.info> - 2011-04-06 09:14 +0000
csiph-web