Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 4678

Macaulay2-1.3.1-8.fc15.i686.rpm

<?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>local variables in a file</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_viewing_spthe_spsymbols_spdefined_spso_spfar.html">next</a> | <a href="_assigning_spvalues.html">previous</a> | <a href="_viewing_spthe_spsymbols_spdefined_spso_spfar.html">forward</a> | <a href="_assigning_spvalues.html">backward</a> | <a href="_variables.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="_variables.html" title="The variables of a complex or co-complex.">variables</a> > <a href="_local_spvariables_spin_spa_spfile.html" title="">local variables in a file</a></div>
<hr/>
<div><h1>local variables in a file</h1>
<div>There is a way to construct variables that can be used within a given source file, and are invisible to code placed in other files.  We use <a href="__co_eq.html" title="assignment of method or new local variable">:=</a> for this.  Assume the code below is placed in a file, and that the file is loaded with the <a href="_load.html" title="read Macaulay2 commands">load</a> command.<table class="examples"><tr><td><pre>i1 : ff := 5

o1 = 5</pre>
</td></tr>
<tr><td><pre>i2 : ff

o2 = 5</pre>
</td></tr>
</table>
The variable above is a local one.  Its value is not available to code in other files.<p/>
Assume the code above is entered directly by the user into Macaulay2.  Then the variable is still a local one and is not available to code previously loaded or to functions previously defined, but it will be available to code loaded subsequently.  We illustrate this below with the variable <tt>j</tt>.<p/>
<table class="examples"><tr><td><pre>i3 : h = () -> j

o3 = h

o3 : FunctionClosure</pre>
</td></tr>
<tr><td><pre>i4 : h()

o4 = j

o4 : Symbol</pre>
</td></tr>
<tr><td><pre>i5 : j = 444

o5 = 444</pre>
</td></tr>
<tr><td><pre>i6 : h()

o6 = 444</pre>
</td></tr>
<tr><td><pre>i7 : j := 555

o7 = 555</pre>
</td></tr>
<tr><td><pre>i8 : h()

o8 = 444</pre>
</td></tr>
<tr><td><pre>i9 : j

o9 = 555</pre>
</td></tr>
</table>
</div>
</div>
</body>
</html>