<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>autoload(Symbol,String) -- arrange for a function to be loaded automatically</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_initialization_spfile.html">next</a> | <a href="_system_spfacilities.html">previous</a> | <a href="_initialization_spfile.html">forward</a> | backward | <a href="_system_spfacilities.html">up</a> | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <div><a href="index.html" title="">Macaulay2Doc</a> > <a href="___The_sp__Macaulay2_splanguage.html" title="">The Macaulay2 language</a> > <a href="_system_spfacilities.html" title="">system facilities</a> > <a href="_autoload_lp__Symbol_cm__String_rp.html" title="arrange for a function to be loaded automatically">autoload(Symbol,String)</a></div> <hr/> <div><h1>autoload(Symbol,String) -- arrange for a function to be loaded automatically</h1> <div class="single"><h2>Synopsis</h2> <ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>autoload(f,x)</tt></div> </dd></dl> </div> </li> <li><span>Function: <a href="_autoload_lp__Symbol_cm__String_rp.html" title="arrange for a function to be loaded automatically">autoload</a></span></li> <li><div class="single">Inputs:<ul><li><span><tt>f</tt>, <span>a <a href="___Symbol.html">symbol</a></span></span></li> <li><span><tt>x</tt>, <span>a <a href="___String.html">string</a></span></span></li> </ul> </div> </li> <li><div class="single">Consequences:<ul><li>arranges for a function named <tt>f</tt> to be automatically loaded from the file <tt>x</tt> the first time it is used. This is accomplished by creating a suitable function that will load the file and assigning the function to <tt>f</tt>.</li> </ul> </div> </li> </ul> </div> <div class="single"><h2>Description</h2> <div><table class="examples"><tr><td><pre>i1 : fn = temporaryFileName() o1 = /tmp/M2-21361-1</pre> </td></tr> <tr><td><pre>i2 : fn << "f = x -> x+1\n" << close o2 = /tmp/M2-21361-1 o2 : File</pre> </td></tr> <tr><td><pre>i3 : autoload(f,fn)</pre> </td></tr> <tr><td><pre>i4 : code f o4 = /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/m2/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 | ------ ----- ----- ------------------ | sym : Symbol -- f /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/m2/autoload.m2:3:29-3:31 | filename : String -- "/tmp/M2-21361-1" /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/m2/autoload.m2:3:33-3:40 | f : FunctionClosure -- {*Function[/builddir/build/BUILD/Macaulay2-1.3.1-r1073. /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/m2/autoload.m2:5:13-5:13</pre> </td></tr> <tr><td><pre>i5 : f 4 --warning: function f redefined o5 = 5</pre> </td></tr> <tr><td><pre>i6 : removeFile fn</pre> </td></tr> </table> </div> </div> </div> </body> </html>