next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc > The Macaulay2 language > system facilities > autoload(Symbol,String)

autoload(Symbol,String) -- arrange for a function to be loaded automatically

Synopsis

Description

i1 : fn = temporaryFileName()

o1 = /tmp/M2-24311-0/0
i2 : fn << "f = x -> x+1\n" << close

o2 = /tmp/M2-24311-0/0

o2 : File
i3 : autoload(f,fn)
i4 : code f

o4 = /usr/share/Macaulay2/Core/autoload.m2:5:20-11:23: --source code:
          sym <- f := x -> (
               load filename;
               if f === value sym 
               then error("symbol '", toString sym, "' didn't acquire a new value in file '", filename, "'");
               (value sym) x
               );
          )
     | symbol     class              value               location of symbol
     | ------     -----              -----               ------------------                                    
     | f        : FunctionClosure -- ...                 /usr/share/Macaulay2/Core/autoload.m2:5:13-5:14
     | sym      : Symbol          -- f                   /usr/share/Macaulay2/Core/autoload.m2:3:29-3:32
     | filename : String          -- "/tmp/M2-24311-0/0" /usr/share/Macaulay2/Core/autoload.m2:3:33-3:41
i5 : f 4

o5 = 5
i6 : removeFile fn