Sophie

Sophie

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

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>what a class is</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_class.html">next</a> | <a href="_making_spnew_spfunctions_spwith_spoptional_sparguments.html">previous</a> | <a href="_installing_spmethods.html">forward</a> | <a href="_making_spnew_spfunctions_spwith_spoptional_sparguments.html">backward</a> | <a href="___The_sp__Macaulay2_splanguage.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="_what_spa_spclass_spis.html" title="">what a class is</a></div>
<hr/>
<div><h1>what a class is</h1>
<div>In Macaulay2 the behavior of a function depends heavily on the types of the arguments it's presented with.  For example, the expression <tt>x+y</tt> means the sum if <tt>x</tt> and <tt>y</tt> are integers, but it means the union if <tt>x</tt> and <tt>y</tt> are sets.  To implement this in a clean fashion, we store the code for doing things with sets in something called <a href="___Set.html" title="the class of all sets">Set</a> and we store the code for doing things with integers in something called <a href="___Z__Z.html" title="the class of all integers">ZZ</a>.  We say that each integer is an <a href="_instance.html" title="whether something has a certain type">instance</a> of <a href="___Z__Z.html" title="the class of all integers">ZZ</a>, and <a href="___Z__Z.html" title="the class of all integers">ZZ</a> is the <a href="_class.html" title="class of an object">class</a> (or type) of each integer.  The function <a href="_class.html" title="class of an object">class</a> provides the class of an object, and the function <a href="_instance.html" title="whether something has a certain type">instance</a> tells whether a given object is an instance of a given class, or a subclass of it, and so on.<p/>
<table class="examples"><tr><td><pre>i1 : class 33

o1 = ZZ

o1 : Ring</pre>
</td></tr>
<tr><td><pre>i2 : instance(33,ZZ)

o2 = true</pre>
</td></tr>
<tr><td><pre>i3 : instance(33,String)

o3 = false</pre>
</td></tr>
</table>
The corresponding mathematical idea is that <a href="___Z__Z.html" title="the class of all integers">ZZ</a> is the set of all integers.<p/>
The class of all classes or types is called <a href="___Type.html" title="the class of all types">Type</a>.<table class="examples"><tr><td><pre>i4 : instance(ZZ,Type)

o4 = true</pre>
</td></tr>
<tr><td><pre>i5 : instance(33,Type)

o5 = false</pre>
</td></tr>
</table>
The class of all objects in the system is <a href="___Thing.html" title="the class of all things">Thing</a>.<table class="examples"><tr><td><pre>i6 : instance(33,Thing)

o6 = true</pre>
</td></tr>
</table>
Everything has a class, and every class has a <a href="_parent.html" title="parent type of an object">parent</a>.  The parent class represents a broader class of objects, and is used to contain code that applies to the broader class.  For example, <a href="___Z__Z.html" title="the class of all integers">ZZ</a> is a ring, and every ring is also a type.<table class="examples"><tr><td><pre>i7 : class ZZ

o7 = Ring

o7 : Type</pre>
</td></tr>
<tr><td><pre>i8 : parent class ZZ

o8 = Type

o8 : Type</pre>
</td></tr>
</table>
Types are implemented as hash tables -- it's a versatile way of storing bits of code that are needed in various situations; the keys for the hash table are constructed in a certain way from the function and the types of its arguments whose details the user doesn't need to know.<p/>
</div>
<div class="single"><h2>See also</h2>
<ul><li><span><a href="_uniform.html" title="test whether elements of a list are of the same class">uniform</a> -- test whether elements of a list are of the same class</span></li>
<li><span><a href="___Thing.html" title="the class of all things">Thing</a> -- the class of all things</span></li>
<li><span><a href="___Nothing.html" title="the empty class">Nothing</a> -- the empty class</span></li>
<li><span><a href="___Type.html" title="the class of all types">Type</a> -- the class of all types</span></li>
<li><span><a href="___Mutable__List.html" title="the class of all mutable lists">MutableList</a> -- the class of all mutable lists</span></li>
<li><span><a href="___Mutable__Hash__Table.html" title="the class of all mutable hash tables">MutableHashTable</a> -- the class of all mutable hash tables</span></li>
<li><span><a href="___Self__Initializing__Type.html" title="the class of all self initializing types">SelfInitializingType</a> -- the class of all self initializing types</span></li>
</ul>
</div>
<div><h3>Menu</h3>
<ul><li><span><a href="_class.html" title="class of an object">class</a> -- class of an object</span></li>
<li><span><a href="_parent.html" title="parent type of an object">parent</a> -- parent type of an object</span></li>
<li><span><a href="_instance.html" title="whether something has a certain type">instance</a> -- whether something has a certain type</span></li>
<li><span>ancestor, see <span><a href="_ancestor_lp__Type_cm__Type_rp.html" title="whether one type is an ancestor of another">ancestor(Type,Type)</a> -- whether one type is an ancestor of another</span></span></li>
</ul>
</div>
</div>
</body>
</html>