File r37/lisp/csl/html/r37_0040.html artifact d688e95f1b part of check-in ed2818cf9f



<A NAME=BEGIN>

<TITLE>BEGIN</TITLE></A>
<b><a href=r37_idx.html>INDEX</a></b><p><p>



<B>BEGIN</B> _ _ _  _ _ _  _ _ _  _ _ _ <B>command</B><P>
<P>
 
<em>begin</em> is used to start a 
<A HREF=r37_0041.html>block</A> statement, which is closed with 
<em>end</em>. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
<em>begin</em>&lt;statement&gt;{<em>;</em> &lt;statement&gt;}* <em>end</em> 
<P>
<P>
<P>
&lt;statement&gt; is any valid REDUCE statement. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<P><PRE><TT>
begin for i := 1:3 do write i end; 


  1
  2
  3     


begin scalar n;n:=1;b:=for i:=1:4 product(x-i);return n end;
 


  1 


b; 

   4        3        2
  X   - 10*X   + 35*X   - 50*X  + 24

</TT></PRE><P>A <em>begin</em>...<em>end</em> block can do actions (such as <em>
write</em>), but 
does not 
return a value unless instructed to by a 
<A HREF=r37_0058.html>return</A> statement, which must 
be the last statement executed in the block. It is unnecessary to insert 
a semicolon before the <em>end</em>. 
<P>
<P>
Local variables, if any, are declared in the first statement immediately 
after <em>begin</em>, and may be defined as <em>scalar, integer,</em> or 
<em>real</em>. 
<A HREF=r37_0188.html>array</A> variables declared 
within a <em>begin</em>...<em>end</em> block 
are global in every case, and 
<A HREF=r37_0199.html>let</A> statements have global 
effects. A 
<A HREF=r37_0199.html>let</A> statement involving a formal parameter affects 
the calling parameter that corresponds to it. 
<A HREF=r37_0199.html>let</A> statements 
involving local variables make global assignments, overwriting outside 
variables by the same name or creating them if they do not exist. You 
can use this feature to affect global variables from procedures, but be 
careful that you do not do it inadvertently. 
<P>
<P>
<P>
<P>


REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]