Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

My template for building packages has, at the end, the following expression that automatically ReadProtects all symbols defined in my pack:

ToExpression[Names["pack`*"], InputForm, SetAttributes[#, {ReadProtected(*,Locked*)}] &]

It works fine, with the exception of cases where I define a constant, like for example: iso=3; This produces the following message (when loading the package):

SetAttributes::sym: Argument 3 at position 1 is expected to be a symbol. >>

Can the automated expression that sets ReadProtected be changed to correct this behavior?

share|improve this question

1 Answer 1

up vote 9 down vote accepted

My guess would be this:

   Function[sym,SetAttributes[sym, {ReadProtected(*,Locked*)}],HoldFirst] 

The problem is that functions defined with # - & notation do not hold their arguments.

share|improve this answer
Works fine, thank you! –  P. Fonseca Apr 30 '12 at 13:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.