home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e031 / 3.ddi / MATHZIP2 / STARTUP / ATTRIBUT.M next >
Encoding:
Text File  |  1991-09-23  |  1.4 KB  |  48 lines

  1.  
  2. Begin["System`"]
  3. (* Attributes.m : to be loaded at dump time : drg *)
  4.  
  5. ClearAttributes::usage = 
  6. "ClearAttributes[s, attr] removes attr from the list of attributes
  7. of the symbol s."
  8.  
  9. SetAttributes::usage =
  10. "SetAttributes[s, attr] adds attr to the list of attributes of
  11. the symbol s."
  12.  
  13. Begin["`Private`"]
  14.  
  15. ClearAttributes[sym_,att_Symbol] := ClearAttributes[sym,{att}]
  16. SetAttributes[sym_,att_Symbol] := SetAttributes[sym,{att}]
  17. ClearAttributes[sym_List,att_] := (Scan[ClearAttributes[#,att]&,sym];)
  18. SetAttributes[sym_List,att_] := (Scan[SetAttributes[#,att]&,sym];)
  19.  
  20. ClearAttributes[sym_Symbol,att_List] :=
  21.     (Attributes[sym] = Complement[Attributes[sym],att];)
  22.  
  23. SetAttributes[sym_Symbol,att_List] :=
  24.     (Attributes[sym] = Union[Attributes[sym],att];)
  25.  
  26. SetAttributes[args___] := Null /; attrError[SetAttributes, args]
  27. ClearAttributes[args___] := Null /; attrError[ClearAttributes, args]
  28.  
  29. attrError[msghead_, sym_, _] :=
  30.     Message[msghead::sym, sym, 1] /; Head[sym] =!= Symbol
  31.  
  32. attrError[msghead_, _, att_] :=
  33.     Message[msghead::sym, att, 2] /; Head[att] =!= Symbol
  34.  
  35. attrError[msghead_, _] := Message[msghead::argr, msghead, 2]
  36.  
  37. attrError[msghead_, args___] :=
  38.     Message[msghead::argrx, msghead, Length[{args}], 2]
  39.  
  40. Clear[nprot, prot];
  41. Remove[nprot, prot];
  42.  
  43. End[ ]  (* "`Private`" *)
  44.  
  45. Protect[ClearAttributes, SetAttributes]
  46.  
  47. End[]  (* "System`" *)
  48.