home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e032 / 3.ddi / FILES / PRELOAD.PAK / AUTOLOAD.M < prev    next >
Encoding:
Text File  |  1992-07-29  |  1.3 KB  |  51 lines

  1. Begin[ "System`"]
  2.  
  3. SystemStub (* export the symbol *)
  4.  
  5. $AutoLoad::usage = "$AutoLoad = True enables the autoloading of system
  6.     packages.   Small memory systems may wish to set $AutoLoad = False."
  7.  
  8. Begin[ "System`Private`"]
  9.  
  10. Unprotect[ SystemStub, AutoLoad]
  11.  
  12. `t (* pattern name *)
  13.  
  14. SystemStub[{fn__Symbol}, file_] := (
  15.         Unprotect[fn];
  16.         (t:Literal[#[___]] := AutoLoad[t, {fn}, file])& /@ {fn};
  17.         SetAttributes[{fn}, ReadProtected];
  18.         Protect[fn];
  19.     )
  20.  
  21. SystemStub[fn_Symbol, file_] := SystemStub[{fn}, file]
  22.  
  23. SetAttributes[ AutoLoad, HoldFirst ]
  24.  
  25. AutoLoad[t_, {fn__}, file_]:=
  26.     Module[{protected},
  27.         protected = Unprotect[fn] ;
  28.         Clear[fn]; (* get rid of AutoLoad definition itself *)
  29.         Protect[Evaluate[protected]];
  30.         If[ $AutoLoad === False,
  31.                 Message[ General::autoload, Head[t], file],
  32.                 AbortProtect[Get[file]]];
  33.         t
  34.     ]
  35.  
  36. If[ $AutoLoad =!= False, $AutoLoad = True]
  37.  
  38. General::autoload = "While evaluating `1` the autoloading of package `2` was
  39.     disabled by the previous setting of $AutoLoad to False.
  40.     The package can be loaded with Get and the evaluation repeated."
  41.  
  42.  
  43. Protect[ SystemStub, AutoLoad ]
  44.  
  45. End[] (* System`Private` *)
  46.  
  47. End[] (* System` *)
  48.  
  49.  
  50.  
  51.