[BACK]Return to asir.texi CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-doc / parts

Diff for /OpenXM/src/asir-doc/parts/asir.texi between version 1.3 and 1.15

version 1.3, 1999/12/21 02:47:31 version 1.15, 2004/07/03 15:50:34
Line 1 
Line 1 
 @comment $OpenXM$  @comment $OpenXM: OpenXM/src/asir-doc/parts/asir.texi,v 1.14 2003/12/21 17:36:29 ohara Exp $
 \BJP  \BJP
 @node $B%f!<%68@8l(B Asir,,, Top  @node $B%f!<%68@8l(B Asir,,, Top
 @chapter $B%f!<%68@8l(B Asir  @chapter $B%f!<%68@8l(B Asir
Line 67  capital alphabetical letter in @b{Asir}.
Line 67  capital alphabetical letter in @b{Asir}.
 @item  @item
 \JP $BJQ?t$N7?$,$J$$(B.  \JP $BJQ?t$N7?$,$J$$(B.
 \EG No types for variables.  \EG No types for variables.
   @*
 \BJP  \BJP
 $B4{$K@bL@$7$?$H$*$j(B, @b{Asir} $B$G07$o$l$kBP>]<+?H$OA4$F2?$i$+$N7?(B  $B4{$K@bL@$7$?$H$*$j(B, @b{Asir} $B$G07$o$l$kBP>]<+?H$OA4$F2?$i$+$N7?(B
 $B$r;}$C$F$$$k(B. $B$7$+$7(B, $B%W%m%0%i%`JQ?t<+BN$O(B, $B$I$N$h$&$JBP>]$G$b(B  $B$r;}$C$F$$$k(B. $B$7$+$7(B, $B%W%m%0%i%`JQ?t<+BN$O(B, $B$I$N$h$&$JBP>]$G$b(B
Line 93  object can be assigned to it.
Line 93  object can be assigned to it.
 @item  @item
 \BJP  \BJP
 $BH!?tFb$NJQ?t$O(B, $B%G%U%)%k%H$G$O2>0z?t$r$3$a$F$9$Y$F6I=jJQ?t(B.  $BH!?tFb$NJQ?t$O(B, $B%G%U%)%k%H$G$O2>0z?t$r$3$a$F$9$Y$F6I=jJQ?t(B.
   @*
 $B$?$@$7(B, @code{extern} $B@k8@$5$l$?JQ?t$O(B, $B%H%C%W%l%Y%k$K$*$1$kBg0hJQ?t$H$J$k(B.  $B$?$@$7(B, @code{extern} $B@k8@$5$l$?JQ?t$O(B, $B%H%C%W%l%Y%k$K$*$1$kBg0hJQ?t$H$J$k(B.
 $B$9$J$o$A(B, $BJQ?t$N%9%3!<%W$OBg0hJQ?t$H6I=jJQ?t$N(B 2 $B<oN`$KC1=c2=$5$l$F$$$k(B.  $B$9$J$o$A(B, $BJQ?t$N%9%3!<%W$OBg0hJQ?t$H6I=jJQ?t$N(B 2 $B<oN`$KC1=c2=$5$l$F$$$k(B.
 $B%H%C%W%l%Y%k(B, $B$9$J$o$A%W%m%s%W%H$KBP$7$FF~NO$5$l$?JQ?t$OA4$FBg0hJQ?t(B  $B%H%C%W%l%Y%k(B, $B$9$J$o$A%W%m%s%W%H$KBP$7$FF~NO$5$l$?JQ?t$OA4$FBg0hJQ?t(B
Line 102  object can be assigned to it.
Line 102  object can be assigned to it.
 \BEG  \BEG
 Variables, together with formal parameters, in a function (procedure)  Variables, together with formal parameters, in a function (procedure)
 are all local to the function by default.  are all local to the function by default.
   @*
 Variables can be global at the top level,  Variables can be global at the top level,
 if they are declared with the key word @code{extern}.  if they are declared with the key word @code{extern}.
 Thus, the scope rule of @b{Asir} is very simple.  Thus, the scope rule of @b{Asir} is very simple.
Line 157  end$
Line 157  end$
 @item  @item
 \JP $B%W%m%0%i%`JQ?t$OBgJ8;z$G;O$^$j(B, $BITDj85(B, $BH!?t$O>.J8;z$G;O$^$k(B.  \JP $B%W%m%0%i%`JQ?t$OBgJ8;z$G;O$^$j(B, $BITDj85(B, $BH!?t$O>.J8;z$G;O$^$k(B.
 \EG Program variables and algebraic indeterminates are distinguished in @b{Asir}.  \EG Program variables and algebraic indeterminates are distinguished in @b{Asir}.
   @*
 \BJP  \BJP
 $B$3$NE@$O(B, $B4{B8$N?t<0=hM}%7%9%F%`$N$[$H$s$I$H0[$J$kE@$G$"$k(B. @b{Asir}  $B$3$NE@$O(B, $B4{B8$N?t<0=hM}%7%9%F%`$N$[$H$s$I$H0[$J$kE@$G$"$k(B. @b{Asir}
 $B$,$3$N;EMM$r:NMQ$7$?$N$O(B, $B%f!<%6$,ITDj85$N$D$b$j$G;HMQ$7$?JQ?t$K(B  $B$,$3$N;EMM$r:NMQ$7$?$N$O(B, $B%f!<%6$,ITDj85$N$D$b$j$G;HMQ$7$?JQ?t$K(B
Line 182  variables and indeterminates in a program.
Line 182  variables and indeterminates in a program.
 @item  @item
 \JP @code{switch} $BJ8(B, @code{goto} $B$,$J$$(B.  \JP @code{switch} $BJ8(B, @code{goto} $B$,$J$$(B.
 \EG No @code{switch} statements, and @code{goto} statements.  \EG No @code{switch} statements, and @code{goto} statements.
   @*
 \JP @code{goto} $B$,$J$$$?$a(B, $BB?=E%k!<%W$r0lEY$KH4$1$k$N$,$d$dJ#;($K$J$k>l9g$,$"$k(B.  \JP @code{goto} $B$,$J$$$?$a(B, $BB?=E%k!<%W$r0lEY$KH4$1$k$N$,$d$dJ#;($K$J$k>l9g$,$"$k(B.
 \EG Lack of @code{goto} statement makes it rather bothering to exit from within multiple loops.  \EG Lack of @code{goto} statement makes it rather bothering to exit from within multiple loops.
   
Line 195  variables and indeterminates in a program.
Line 195  variables and indeterminates in a program.
 Comma expressions are allowed only in @code{A}, @code{B} and @code{C}  Comma expressions are allowed only in @code{A}, @code{B} and @code{C}
 of the constructs @code{for (A;B;C)} or @code{while(A)}.  of the constructs @code{for (A;B;C)} or @code{while(A)}.
 \E  \E
   @*
 \JP $B$3$l$O(B, $B%j%9%H$r@5<0$J%*%V%8%'%/%H$H$7$F2C$($?$3$H$K$h$k(B.  \JP $B$3$l$O(B, $B%j%9%H$r@5<0$J%*%V%8%'%/%H$H$7$F2C$($?$3$H$K$h$k(B.
 \EG This limitation came from adopting lists as legal data objects for @b{Asir}.  \EG This limitation came from adopting lists as legal data objects for @b{Asir}.
   
Line 227  Use of lists enables to write programs more easily, sh
Line 227  Use of lists enables to write programs more easily, sh
 comprehensible than use of structure like C programs.  comprehensible than use of structure like C programs.
 \E  \E
   
   \BJP
 @item  @item
   $B%f!<%6Dj5AH!?t$K$*$1$k0l9T%X%k%W(B.  Emacs-Lisp $B$KN`;w$7$?5!G=$G$"$k(B.
   $B>\$7$/$O(B, @xref{$B%f!<%6Dj5AH!?t(B} $B$r8+$h(B.
   \E
   
   @item
 \JP $B%f!<%6Dj5AH!?t$K$*$1$k%*%W%7%g%s;XDj(B.  \JP $B%f!<%6Dj5AH!?t$K$*$1$k%*%W%7%g%s;XDj(B.
 \EG Options can be specified in calling user defined functions.  \EG Options can be specified in calling user defined functions.
   
Line 236  comprehensible than use of structure like C programs.
Line 242  comprehensible than use of structure like C programs.
 @end itemize  @end itemize
   
 \BJP  \BJP
   @noindent
   Asir $B$G$O<!$N8l6g$,%-!<%o!<%I$H$7$FDj$a$i$l$F$$$k(B.
   @itemize
   @item C $B8@8l$KM3Mh(B:
   
   @code{break}, @code{continue}, @code{do}, @code{else}, @code{extern},
   @code{for}, @code{if}, @code{return}, @code{static}, @code{struct},
   @code{while}
   @item C $B8@8l$+$i$N3HD%(B:
   
   @code{def}, @code{endmodule}, @code{function}, @code{global},
   @code{local}, @code{localf}, @code{module}
   @item $BH!?t(B:
   
   @code{car}, @code{cdr}, @code{getopt}, @code{newstruct}, @code{map},
   @code{pari}, @code{quote}, @code{recmap}, @code{timer}
   @end itemize
   \E
   
   \BJP
 @node $B%f!<%6Dj5AH!?t$N=q$-J}(B,,, $B%f!<%68@8l(B Asir  @node $B%f!<%6Dj5AH!?t$N=q$-J}(B,,, $B%f!<%68@8l(B Asir
 @section $B%f!<%6Dj5AH!?t$N=q$-J}(B  @section $B%f!<%6Dj5AH!?t$N=q$-J}(B
 \E  \E
Line 254  comprehensible than use of structure like C programs.
Line 280  comprehensible than use of structure like C programs.
 * return $BJ8(B::  * return $BJ8(B::
 * if $BJ8(B::  * if $BJ8(B::
 * $B%k!<%W(B break return continue::  * $B%k!<%W(B break return continue::
   * $B9=B$BNDj5A(B::
 * $B$5$^$6$^$J<0(B::  * $B$5$^$6$^$J<0(B::
 * $B%W%j%W%m%;%C%5(B::  * $B%W%j%W%m%;%C%5(B::
 * $B%*%W%7%g%s;XDj(B::  * $B%*%W%7%g%s;XDj(B::
   * $B%b%8%e!<%k(B::
 \E  \E
 \BEG  \BEG
 * User defined functions::  * User defined functions::
Line 267  comprehensible than use of structure like C programs.
Line 295  comprehensible than use of structure like C programs.
 * return statement::  * return statement::
 * if statement::  * if statement::
 * loop break return continue::  * loop break return continue::
   * structure definition::
 * various expressions::  * various expressions::
 * preprocessor::  * preprocessor::
 * option::  * option::
   * module::
 \E  \E
 @end menu  @end menu
   
Line 345  def c(N)
Line 375  def c(N)
         @}          @}
     return A;      return A;
 @}  @}
   
   @tex
   /* $A+B$ */
   @end tex
   
   def add(A,B)
   "add two numbers."
   @{
       return A+B;
   @}
 @end example  @end example
   
 @noindent  @noindent
Line 370  ICJ
Line 410  ICJ
   
 @noindent  @noindent
 \BJP  \BJP
   3 $B$DL\$NNc$G$O(B, $B0z?tJB$S$N$"$H$KJ8;zNs$,CV$+$l$F$$$k$,!"$3$l$O(B
   Emacs-Lisp $B$N4X?tDj5A$KN`;w$N5!G=$G!"%X%k%WMQ$NJ8;zNs$G$"$k!#(B
   $B$3$NNc$N>l9g!"(B@code{help(add)} $B$K$h$C$F$3$NJ8;zNs$,=PNO$5$l$k!#(B
   \E
   @table @t
   \JP @item $B;2>H(B
   \EG @item References
   @fref{help}.
   @end table
   
   @noindent
   \BJP
 $B0J2<$G$O(B, C $B$K$h$k%W%m%0%i%_%s%0$N7P83$,$J$$?M$N$?$a$K(B, @b{Asir} $B8@8l(B  $B0J2<$G$O(B, C $B$K$h$k%W%m%0%i%_%s%0$N7P83$,$J$$?M$N$?$a$K(B, @b{Asir} $B8@8l(B
 $B$K$h$k%W%m%0%i%`$N=q$-J}$r2r@b$9$k(B.  $B$K$h$k%W%m%0%i%`$N=q$-J}$r2r@b$9$k(B.
 \E  \E
Line 434  All the program variables are initialized to the value
Line 486  All the program variables are initialized to the value
   
 \BJP  \BJP
 @item $BITDj85(B  @item $BITDj85(B
 $B>.J8;z$G;O$^$j(B, $B%"%k%U%!%Y%C%H(B, $B?t;z(B, @samp{_} $B$+$i$J$kJ8;zNs(B  $B>.J8;z$G;O$^$j(B, $B%"%k%U%!%Y%C%H(B, $B?t;z(B, @samp{_} $B$+$i$J$kJ8;zNs(B,
   $B$^$?$O%7%s%0%k%/%*!<%H$G0O$^$l$?J8;zNs(B, $B$b$7$/$OH!?t7A<0(B.
 $BITDj85$H$O(B, $BB?9`<04D$r9=@.$9$k:]$KE:2C$5$l$kJQ?t$r$$$&(B. @b{Asir} $B$K(B  $BITDj85$H$O(B, $BB?9`<04D$r9=@.$9$k:]$KE:2C$5$l$kJQ?t$r$$$&(B.  @b{Asir} $B$K(B
 $B$*$$$F$O(B, $BITDj85$OCM$r$b$?$J$$D61[E*$J85$G$"$j(B, $BITDj85$X$NCM$NBeF~$O(B  $B$*$$$F$O(B, $BITDj85$OCM$r$b$?$J$$D61[E*$J85$G$"$j(B, $BITDj85$X$NCM$NBeF~$O(B
 $B5v$5$l$J$$(B.  $B5v$5$l$J$$(B.
 \E  \E
Line 455  An indeterminate cannot have any value.  No assignment
Line 507  An indeterminate cannot have any value.  No assignment
 x  x
 [4] X^2+X+1;  [4] X^2+X+1;
 x^2+x+1  x^2+x+1
   [5] A='Dx'*(x-1)+x*y-y;
   (y+Dx)*x-y-Dx
   [6] function foo(x,y);
   [7] B=foo(x,y)*x^2-1;
   foo(x,y)*x^2-1
 @end example  @end example
 @end table  @end table
   
Line 574  def afo(X) @{
Line 631  def afo(X) @{
 @samp{/*} $B$,$$$/$D$"$C$F$b:G=i$N$b$N$N$_$,M-8z$H$J$j(B, $B:G=i$K8=$l$?(B  @samp{/*} $B$,$$$/$D$"$C$F$b:G=i$N$b$N$N$_$,M-8z$H$J$j(B, $B:G=i$K8=$l$?(B
 @samp{*/} $B$G%3%a%s%H$O=*N;$7$?$H8+$J$5$l$k(B. $B%W%m%0%i%`$J$I$G(B, $B%3%a%s%H(B  @samp{*/} $B$G%3%a%s%H$O=*N;$7$?$H8+$J$5$l$k(B. $B%W%m%0%i%`$J$I$G(B, $B%3%a%s%H(B
 $B$r4^$`2DG=@-$,$"$kItJ,$r%3%a%s%H%"%&%H$7$?>l9g$K$O(B, @code{#if 0},  $B$r4^$`2DG=@-$,$"$kItJ,$r%3%a%s%H%"%&%H$7$?>l9g$K$O(B, @code{#if 0},
 @code{#endif}$B$r;H$($P$h$$(B. (@xref{$B%W%j%W%m%;%C%5(B})  @code{#endif}$B$r;H$($P$h$$(B. (@xref{$B%W%j%W%m%;%C%5(B}.)
 \E  \E
 \BEG  \BEG
 A comment can span to several lines, but it cannot be nested.  A comment can span to several lines, but it cannot be nested.
Line 583  in the subsequent text exist, and the comment terminat
Line 640  in the subsequent text exist, and the comment terminat
 @samp{*/}.  @samp{*/}.
   
 In order to comment out a program part that may contain comments in it,  In order to comment out a program part that may contain comments in it,
 use the pair, @code{#if 0} and @code{#endif}. (@xref{preprocessor})  use the pair, @code{#if 0} and @code{#endif}. (@xref{preprocessor}.)
 \E  \E
   
 @example  @example
Line 650  S = sum(N);
Line 707  S = sum(N);
 \BJP  \BJP
 $B$N$h$&$K(B, $B<0$K=*C<5-9f(B (@samp{;} $B$^$?$O(B @samp{$}) $B$r$D$1$?$b$N$G$"$k(B.  $B$N$h$&$K(B, $B<0$K=*C<5-9f(B (@samp{;} $B$^$?$O(B @samp{$}) $B$r$D$1$?$b$N$G$"$k(B.
 $B$3$NC1J85Z$SN`;w$N(B @code{return} $BJ8(B, @code{break} $BJ8$J$I$,J8$N:G>.9=@.(B  $B$3$NC1J85Z$SN`;w$N(B @code{return} $BJ8(B, @code{break} $BJ8$J$I$,J8$N:G>.9=@.(B
 $BC10L$H$J$k(B. @code{if} $BJ8$d(B @code{for} $BJ8$NDj5A(B (@xref{$BJ8K!$N>\:Y(B}) $B$r8+$l(B  $BC10L$H$J$k(B. @code{if} $BJ8$d(B @code{for} $BJ8$NDj5A(B (@ref{$BJ8K!$N>\:Y(B}) $B$r8+$l(B
 $B$P$o$+$kDL$j(B, $B$=$l$i$NK\BN$O(B, $BC1$J$k0l$D$NJ8$H$7$FDj5A$5$l$F$$$k(B. $BDL>o(B  $B$P$o$+$kDL$j(B, $B$=$l$i$NK\BN$O(B, $BC1$J$k0l$D$NJ8$H$7$FDj5A$5$l$F$$$k(B. $BDL>o(B
 $B$O(B, $BK\BN$K$OJ#?t$NJ8$,=q$1$k$3$H$,I,MW$H$J$k(B.  $B$3$N$h$&$J>l9g(B,  $B$O(B, $BK\BN$K$OJ#?t$NJ8$,=q$1$k$3$H$,I,MW$H$J$k(B.  $B$3$N$h$&$J>l9g(B,
 @samp{@{} $B$H(B @samp{@}} $B$GJ8$NJB$S$r3g$C$F(B, $B0l$D$NJ8$H$7$F07$&$3$H$,$G(B  @samp{@{} $B$H(B @samp{@}} $B$GJ8$NJB$S$r3g$C$F(B, $B0l$D$NJ8$H$7$F07$&$3$H$,$G(B
Line 834  if ( expression1 ) @{
Line 891  if ( expression1 ) @{
 @noindent  @noindent
 \JP $B$H$7$J$1$l$P$J$i$J$$(B.  \JP $B$H$7$J$1$l$P$J$i$J$$(B.
   
   \BJP
   @noindent
   $B4X?t$NCf$G$J$/(B, top level $B$G(B @code{if} $BJ8$rMQ$$$k$H$-$O(B @code{$} $B$^$?$O(B @code{;}
   $B$G=*N;$9$kI,MW$,$"$k(B.
   $B$3$l$i$,$J$$$H<!$NJ8$,$h$_$H$P$5$l$k(B.
   \E
   \BEG
   @noindent
   When @code{if} is used in the top level, the @code{if} expression should be
   terminated with @code{$} or @code{;}.
   If there is no terminator, the next expression will be skipped to be evaluated.
   \E
   
 \BJP  \BJP
 @node $B%k!<%W(B break return continue,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B  @node $B%k!<%W(B break return continue,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
 @subsection $B%k!<%W(B, @code{break}, @code{return}, @code{continue}  @subsection $B%k!<%W(B, @code{break}, @code{return}, @code{continue}
Line 858  the @code{while} statement, the @code{for} statement, 
Line 928  the @code{while} statement, the @code{for} statement, 
 @item  @item
 \JP @code{while} $BJ8(B  \JP @code{while} $BJ8(B
 \EG @code{while} statement  \EG @code{while} statement
   @*
 \JP $B7A<0$O(B,  \JP $B7A<0$O(B,
 \EG It has the following form.  \EG It has the following form.
   
Line 882  infinite loop.
Line 952  infinite loop.
 @item  @item
 \JP @code{for} $BJ8(B  \JP @code{for} $BJ8(B
 \EG @code{for} statement  \EG @code{for} statement
   @*
 \JP $B7A<0$O(B,  \JP $B7A<0$O(B,
 \EG It has the following form.  \EG It has the following form.
   
 @example  @example
 \JP for ( $B<0JB$S(B-1; $B<0(B; $B<0JB$S(B-2 ) $BJ8(B  \JP for ( $B<0JB$S(B-1; $B<0(B; $B<0JB$S(B-2 ) $BJ8(B
 \EG for ( expression list-1; expression; expression list-2 ) statement  \EG for ( expr list-1; expr; expr list-2 ) statement
 @end example  @end example
   
 \JP $B$G(B, $B$3$l$O(B  \JP $B$G(B, $B$3$l$O(B
Line 903  while ( $B<0(B ) @{
Line 973  while ( $B<0(B ) @{
 @}  @}
 \E  \E
 \BEG  \BEG
 expression list-1 (transformed into a sequence of simple statement)  expr list-1 (transformed into a sequence of simple statement)
 while ( expression ) @{  while ( expr ) @{
     statement      statement
     expression list-2 (transformed into a sequence of simple statement)      expr list-2 (transformed into a sequence of simple statement)
 @}  @}
 \E  \E
 @end example  @end example
Line 916  while ( expression ) @{
Line 986  while ( expression ) @{
 @item  @item
 \JP @code{do} $BJ8(B  \JP @code{do} $BJ8(B
 \EG @code{do} statement  \EG @code{do} statement
   @*
 @example  @example
 \BJP  \BJP
 do @{  do @{
Line 957  the control to a certain point of the loop.
Line 1027  the control to a certain point of the loop.
   
 @item  @item
 @code{break}  @code{break}
   @*
 \JP @code{break} $BJ8$O(B, $B$=$l$r0O$`%k!<%W$r0l$D$@$1H4$1$k(B.  \JP @code{break} $BJ8$O(B, $B$=$l$r0O$`%k!<%W$r0l$D$@$1H4$1$k(B.
 \EG The @code{break} statement is used to exit the inner most loop.  \EG The @code{break} statement is used to exit the inner most loop.
 @item  @item
 @code{return}  @code{return}
   @*
 \BJP  \BJP
 @code{return} $BJ8$O(B, $B0lHL$KH!?t$+$iH4$1$k$?$a$NJ8$G$"$j(B,  @code{return} $BJ8$O(B, $B0lHL$KH!?t$+$iH4$1$k$?$a$NJ8$G$"$j(B,
 $B%k!<%W$NCf$+$i$G$bM-8z$G$"$k(B.  $B%k!<%W$NCf$+$i$G$bM-8z$G$"$k(B.
Line 974  and it is also effective in a loop.
Line 1044  and it is also effective in a loop.
   
 @item  @item
 @code{continue}  @code{continue}
   @*
 \BJP  \BJP
 @code{continue} $BJ8$O(B, $B%k!<%W$NK\BN$NJ8$NKvC<$K@)8f$r0\$9(B.  @code{continue} $BJ8$O(B, $B%k!<%W$NK\BN$NJ8$NKvC<$K@)8f$r0\$9(B.
 $BNc$($P(B @code{for} $BJ8$G$O(B, $B:G8e$N<0JB$S$N<B9T$r9T$$(B, @code{while}  $BNc$($P(B @code{for} $BJ8$G$O(B, $B:G8e$N<0JB$S$N<B9T$r9T$$(B, @code{while}
Line 990  statement, and the termination condition will be evalu
Line 1060  statement, and the termination condition will be evalu
 @end itemize  @end itemize
   
 \BJP  \BJP
   @node $B9=B$BNDj5A(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
   @subsection $B9=B$BNDj5A(B
   \E
   \BEG
   @node structure definition,,, Writing user defined functions
   @subsection structure definition
   \E
   
   \BJP
   $B9=B$BN$H$O(B, $B3F@.J,$NMWAG$,L>A0$G%"%/%;%9$G$-$k8GDjD9G[Ns$H;W$C$F$h$$(B.
   $B3F9=B$BN$OL>A0$G6hJL$5$l$k(B. $B9=B$BN$O(B, @code{struct} $BJ8$K$h$j@k8@$5$l$k(B.
   $B9=B$BN$,@k8@$5$l$k$H$-(B, asir $B$OFbIt$G9=B$BN$N$=$l$>$l$N7?$K8GM-$N<1JL(B
   $BHV9f$r$D$1$k(B.  $B$3$NHV9f$O(B, $BAH$_9~$_4X?t(B @code{struct_type} $B$K$h$j<hF@(B
   $B$G$-$k(B.
   $B$"$k7?$N9=B$BN$O(B, $BAH$_9~$_4X?t(B @code{newstruct} $B$K$h$j@8@.$5$l$k(B.
   $B9=B$BN$N3F%a%s%P$O(B, $B1i;;;R(B @code{->} $B$K$h$j%"%/%;%9$9$k(B.
   $B%a%s%P$,9=B$BN$N>l9g(B, @code{->} $B$K$h$k;XDj$OF~$l;R$K$G$-$k(B.
   \E
   
   \BEG
   A structure data type is a fixed length array and each component of the array
   is accessed by its name. Each type of structure is distinguished by its name.
   A structure data type is declared by @code{struct} statement.
   A structure object is generated by a builtin function @code{newstruct}.
   Each member of a structure is accessed by an operatator @code{->}.
   If a member of a structure is again a structure, then the specification
   by @code{->} can be nested.
   \E
   
   @example
   [1] struct rat @{num,denom@};
   0
   [2] A = newstruct(rat);
   @{0,0@}
   [3] A->num = 1;
   1
   [4] A->den = 2;
   2
   [5] A;
   @{1,2@}
   [6] struct_type(A);
   1
   @end example
   
   @table @t
   \JP @item $B;2>H(B
   \EG @item References
   @fref{newstruct}, @fref{struct_type}
   @end table
   
   \BJP
 @node $B$5$^$6$^$J<0(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B  @node $B$5$^$6$^$J<0(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
 @subsection $B$5$^$6$^$J<0(B  @subsection $B$5$^$6$^$J<0(B
 \E  \E
Line 1006  statement, and the termination condition will be evalu
Line 1127  statement, and the termination condition will be evalu
 @item  @item
 \JP $B2C8:>h=|(B, $BQQ(B  \JP $B2C8:>h=|(B, $BQQ(B
 \EG addition, subtraction, multiplication, division, exponentiation  \EG addition, subtraction, multiplication, division, exponentiation
   @*
 \BJP  \BJP
 $BQQ$O(B, @samp{^} $B$K$h$jI=$9(B. $B=|;;(B @samp{/} $B$O(B, $BBN$H$7$F$N1i;;$KMQ$$$k(B.  $BQQ$O(B, @samp{^} $B$K$h$jI=$9(B. $B=|;;(B @samp{/} $B$O(B, $BBN$H$7$F$N1i;;$KMQ$$$k(B.
 $BNc$($P(B, @code{2/3} $B$OM-M}?t$N(B @code{2/3} $B$rI=$9(B.  $BNc$($P(B, @code{2/3} $B$OM-M}?t$N(B @code{2/3} $B$rI=$9(B.
Line 1027  x+1  A^2*B*afo X/3 
Line 1148  x+1  A^2*B*afo X/3 
 @item  @item
 \JP $B%$%s%G%C%/%9$D$-$NJQ?t(B  \JP $B%$%s%G%C%/%9$D$-$NJQ?t(B
 \EG programming variables with indices  \EG programming variables with indices
   @*
 \BJP  \BJP
 $B%Y%/%H%k(B, $B9TNs(B, $B%j%9%H$NMWAG$O%$%s%G%C%/%9$rMQ$$$k$3$H$K$h$j<h$j=P$;$k(B.  $B%Y%/%H%k(B, $B9TNs(B, $B%j%9%H$NMWAG$O%$%s%G%C%/%9$rMQ$$$k$3$H$K$h$j<h$j=P$;$k(B.
 $B%$%s%G%C%/%9$O(B 0 $B$+$i;O$^$k$3$H$KCm0U$9$k(B. $B<h$j=P$7$?MWAG$,%Y%/%H%k(B,  $B%$%s%G%C%/%9$O(B 0 $B$+$i;O$^$k$3$H$KCm0U$9$k(B. $B<h$j=P$7$?MWAG$,%Y%/%H%k(B,
Line 1048  V[0] M[1][2]
Line 1169  V[0] M[1][2]
 @item  @item
 \JP $BHf3S1i;;(B  \JP $BHf3S1i;;(B
 \EG comparison operation  \EG comparison operation
   @*
 \BJP  \BJP
 $BEy$7$$(B (@samp{==}), $BEy$7$/$J$$(B (@samp{!=}), $BBg>.(B (@samp{>}, @samp{<},  $BEy$7$$(B (@samp{==}), $BEy$7$/$J$$(B (@samp{!=}), $BBg>.(B (@samp{>}, @samp{<},
 @samp{>=}, @samp{<=}) $B$N(B 2 $B9`1i;;$,$"$k(B. $B??$J$i$PM-M}?t$N(B 1, $B56$J$i$P(B  @samp{>=}, @samp{<=}) $B$N(B 2 $B9`1i;;$,$"$k(B. $B??$J$i$PM-M}?t$N(B 1, $B56$J$i$P(B
Line 1065  or 0 for the false.
Line 1186  or 0 for the false.
 @item  @item
 \JP $BO@M}<0(B  \JP $BO@M}<0(B
 \EG logical expression  \EG logical expression
   @*
 \BJP  \BJP
 $BO@M}@Q(B (@samp{&&}), $BO@M}OB(B (@samp{||}) $B$N(B 2 $B9`1i;;$H(B, $BH]Dj(B (@samp{!})  $BO@M}@Q(B (@samp{&&}), $BO@M}OB(B (@samp{||}) $B$N(B 2 $B9`1i;;$H(B, $BH]Dj(B (@samp{!})
 $B$,MQ0U$5$l$F$$$k(B. $BCM$O$d$O$j(B 1, 0 $B$G$"$k(B.  $B$,MQ0U$5$l$F$$$k(B. $BCM$O$d$O$j(B 1, 0 $B$G$"$k(B.
Line 1082  and 0 for the false.
Line 1203  and 0 for the false.
 @item  @item
 \JP $BBeF~(B  \JP $BBeF~(B
 \EG assignment  \EG assignment
   @*
 \BJP  \BJP
 $BDL>o$NBeF~$O(B @samp{=} $B$G9T$&(B. $B$3$N$[$+(B, $B;;=Q1i;;;R$HAH$_9g$o$;$F(B  $BDL>o$NBeF~$O(B @samp{=} $B$G9T$&(B. $B$3$N$[$+(B, $B;;=Q1i;;;R$HAH$_9g$o$;$F(B
 $BFC<l$JBeF~$r9T$&$3$H$b$G$-$k(B.  $BFC<l$JBeF~$r9T$&$3$H$b$G$-$k(B.
Line 1095  There are special assignments combined with arithmetic
Line 1216  There are special assignments combined with arithmetic
   
 @example  @example
 \JP A = 2  A *= 3 ($B$3$l$O(B A = A*3 $B$HF1$8(B; $B$=$NB>$N1i;;;R$bF1MM(B)  \JP A = 2  A *= 3 ($B$3$l$O(B A = A*3 $B$HF1$8(B; $B$=$NB>$N1i;;;R$bF1MM(B)
 \EG A = 2  A *= 3 (the same as A = A*3; The other combination are alike.)  \EG A = 2  A *= 3 (the same as A = A*3; The others are alike.)
 @end example  @end example
 @item  @item
 \JP $BH!?t8F$S=P$7(B  \JP $BH!?t8F$S=P$7(B
 \EG function call  \EG function call
   @*
 \JP $BH!?t8F$S=P$7$b<0$N0l<o$G$"$k(B.  \JP $BH!?t8F$S=P$7$b<0$N0l<o$G$"$k(B.
 \EG A function call is also an expression.  \EG A function call is also an expression.
 @item  @item
 @samp{++}, @samp{--}  @samp{++}, @samp{--}
   @*
 \JP $B$3$l$i$O(B, $BJQ?t$NA08e$K$D$$$F(B, $B$=$l$>$l<!$N$h$&$JA`:n(B, $BCM$rI=$9(B.  \JP $B$3$l$i$O(B, $BJQ?t$NA08e$K$D$$$F(B, $B$=$l$>$l<!$N$h$&$JA`:n(B, $BCM$rI=$9(B.
 \BEG  \BEG
 These operators are attached to or before a program variable,  These operators are attached to or before a program variable,
Line 1121  A--  $BCM$O85$N(B A $B$NCM(B, A = A-1
Line 1242  A--  $BCM$O85$N(B A $B$NCM(B, A = A-1
 \BEG  \BEG
 A++  the expression value is the previous value of A, and A = A+1  A++  the expression value is the previous value of A, and A = A+1
 A--  the expression value is the previous value of A, and A = A-1  A--  the expression value is the previous value of A, and A = A-1
 ++A  A = A+1, and the expression value is the value after increment of A  ++A  A = A+1, and the value is the one after increment of A
 --A  A = A-1, and the expression value is the value after decrement of A  --A  A = A-1, and the value is the one after decrement of A
 \E  \E
 @end example  @end example
   
Line 1156  through @code{cpp}.  This enables @b{Asir} user to use
Line 1277  through @code{cpp}.  This enables @b{Asir} user to use
 @itemize @bullet  @itemize @bullet
 @item  @item
 @code{#include}  @code{#include}
   @*
 \BJP  \BJP
 @code{cpp} $B$KFC$K0z?t$rEO$5$J$$$?$a(B, $B%$%s%/%k!<%I%U%!%$%k$O(B,  UNIX $B$G$O(B $B%$%s%/%k!<%I%U%!%$%k$O(B, Asir $B$N%i%$%V%i%j%G%#%l%/%H%j(B
 @code{#include} $B$,=q$+$l$F$$$k%U%!%$%k$HF1$8%G%#%l%/%H%j$G%5!<%A$5$l$k(B.  ($B4D6-JQ?t(B @b{ASIR_LIBDIR} $B$G;XDj$5$l$?%G%#%l%/%H%j(B)
   $B$H(B @code{#include} $B$,=q$+$l$F$$$k%U%!%$%k$HF1$8%G%#%l%/%H%j$r%5!<%A$9$k(B.
   UNIX $B0J30$G$O(B @code{cpp} $B$KFC$K0z?t$rEO$5$J$$$?$a(B,
   @code{#include} $B$,=q$+$l$F$$$k%U%!%$%k$HF1$8%G%#%l%/%H%j$N$_$r%5!<%A$9$k(B.
 \E  \E
 \BEG  \BEG
 Include files are searched within the same directory as the file  Include files are searched within the same directory as the file
Line 1168  containing @code{#include} so that no arguments are pa
Line 1292  containing @code{#include} so that no arguments are pa
   
 @item  @item
 @code{#define}  @code{#define}
   @*
 \JP $B$3$l$O(B, C $B$K$*$1$k$N$HA4$/F1MM$KMQ$$$k$3$H$,$G$-$k(B.  \JP $B$3$l$O(B, C $B$K$*$1$k$N$HA4$/F1MM$KMQ$$$k$3$H$,$G$-$k(B.
 \EG This can be used just as in C language.  \EG This can be used just as in C language.
   
 @item  @item
 @code{#if}  @code{#if}
   @*
 \BJP  \BJP
 @code{/*}, @code{*/} $B$K$h$k%3%a%s%H$OF~$l;R$K$G$-$J$$$N$G(B, $B%W%m%0%i%`(B  @code{/*}, @code{*/} $B$K$h$k%3%a%s%H$OF~$l;R$K$G$-$J$$$N$G(B, $B%W%m%0%i%`(B
 $B$NBg$-$JItJ,$r%3%a%s%H%"%&%H$9$k:]$K(B, @code{#if 0}, @code{#endif}  $B$NBg$-$JItJ,$r%3%a%s%H%"%&%H$9$k:]$K(B, @code{#if 0}, @code{#endif}
Line 1228  because such comments cannot be nested.
Line 1352  because such comments cannot be nested.
 #define MAX(a,b) ((a)>(b)?(a):(b))  #define MAX(a,b) ((a)>(b)?(a):(b))
 @end example  @end example
   
   \BJP
   @noindent
   C $B$N%W%j%W%m%;%C%5$rN.MQ$7$F$$$k$?$a(B, $B%W%j%W%m%;%C%5$O(B @code{$} $B$r@5$7$/=hM}$G$-$J$$(B.
   $B$?$H$($P(B @code{LIST} $B$,Dj5A$5$l$F$$$F$b(B
   @code{LIST$}$B$OCV49$5$l$J$$(B. @code{$} $B$NA0$K6uGr$r$*$$$F(B
   @code{LIST $} $B$H=q$+$J$$$H$$$1$J$$(B.
   \E
   \BEG
   @noindent
   Since we are utilizing the C preprocessor, it cannot properly preprocess expressions
   with @code{$}.
   For example, even if @code{LIST} is defined, @code{LIST} in the expression
   @code{LIST$} is not replaced.  Add a blank before @code{$}, i.e.,
   write as @code{LIST $} to make the proprocessor replace it properly.
   \E
   
 \BJP  \BJP
 @node $B%*%W%7%g%s;XDj(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B  @node $B%*%W%7%g%s;XDj(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
Line 1312  After @samp{|} one can append any number of options se
Line 1451  After @samp{|} one can append any number of options se
 [100] xxx(1,2,x^2-1,[1,2,3]|proc=1,index=5);  [100] xxx(1,2,x^2-1,[1,2,3]|proc=1,index=5);
 @end example  @end example
   
   \BJP
   $B$5$i$K(B, $B%*%W%7%g%s$r(B @code{key1=value1,key2=value2,...} $B$N$h$&$K(B
   @samp{,} $B$G6h@Z$C$FEO$9Be$o$j$K(B, $BFCJL$J%-!<%o!<%I(B @code{option_list}
   $B$H%*%W%7%g%s%j%9%H(B @code{[["key1",value1],["key2",value2],...]}
   $B$rMQ$$$FEO$9$3$H$b2DG=$G$"$k(B.
   
   @example
   [101] dp_gr_main([x^2+y^2-1,x*y-1]|option_list=[["v",[x,y]],["order",[[x,5,y,1]]]]);
   @end example
   
   $BFC$K(B, $B0z?t$J$7$N(B @code{getopt()} $B$O%*%W%7%g%s%j%9%H$rJV$9$N$G(B,
   $B%*%W%7%g%s$r$H$k4X?t$+$i(B, $B%*%W%7%g%s$r$H$k4X?t$r8F$S=P$9$H$-$K$OM-MQ$G$"$k(B.
   
   @example
   % cat foo.rr
   def foo(F)
   @{
       OPTS=getopt();
       return factor(F|option_list=OPTS);
   @}
   @end example
   
   @example
   [3] load("foo.rr")$
   [4] foo(x^5-1|mod=11);
   [[1,1],[x+6,1],[x+2,1],[x+10,1],[x+7,1],[x+8,1]]
   @end example
   \E
   
   \BJP
   @node $B%b%8%e!<%k(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
   @subsection $B%b%8%e!<%k(B
   \E
   \BEG
   @node module,,, Writing user defined functions
   @subsection module
   \E
   
   \BJP
   $B%i%$%V%i%j$GDj5A$5$l$F$$$k4X?t(B, $BJQ?t$r%+%W%;%k2=$9$k;EAH$_$,(B
   $B%b%8%e!<%k(B (module) $B$G$"$k(B.
   $B$O$8$a$K%b%8%e!<%k$rMQ$$$?%W%m%0%i%`$NNc$r$"$2$h$&(B.
   \E
   \BEG
   Function names and variables in a library may be
   encapsulated by module.
   Let us see an example of using module
   \E
   
   @example
   module stack;
   
   static Sp $
   Sp = 0$
   static Ssize$
   Ssize = 100$
   static Stack $
   Stack = newvect(Ssize)$
   localf push $
   localf pop $
   
   def push(A) @{
     if (Sp >= Ssize) @{print("Warning: Stack overflow\nDiscard the top"); pop();@}
     Stack[Sp] = A;
     Sp++;
   @}
   def pop() @{
     local A;
     if (Sp <= 0) @{print("Stack underflow"); return 0;@}
     Sp--;
     A = Stack[Sp];
     return A;
   @}
   endmodule;
   
   def demo() @{
     stack.push(1);
     stack.push(2);
     print(stack.pop());
     print(stack.pop());
   @}
   @end example
   
   \BJP
   $B%b%8%e!<%k$O(B @code{module} $B%b%8%e!<%kL>(B  $B!A(B @code{endmodule}$B$G0O$`(B.
   $B%b%8%e!<%k$OF~$l;R$K$O$G$-$J$$(B.
   $B%b%8%e!<%k$NCf$@$1$G;H$&Bg0hJQ?t$O(B @code{static} $B$G@k8@$9$k(B.
   $B$3$NJQ?t$O%b%8%e!<%k$N30$+$i$O;2>H$b$G$-$J$$$7JQ99$b$G$-$J$$(B.
   $B%b%8%e!<%k$N30$NBg0hJQ?t$O(B @code{extern} $B$G@k8@$9$k(B.
   \E
   \BEG
   Module is encapsulated by the sentences
   @code{module} module name
   and
   @code{endmodule}.
   A variable of a module is declared with the key word @code{static}.
   The static variables cannot be refered nor changed out of the module,
   but it can be refered and changed in any functions in the module.
   A global variable which can be refered and changed at any place
   is declared with the key word @code{extern}.
   \E
   
   \BJP
   $B%b%8%e!<%kFbIt$GDj5A$9$k4X?t$O(B @code{localf} $B$rMQ$$$F@k8@$7$J$$$H$$$1$J$$(B.
   $B>e$NNc$G$O(B @code{push} $B$H(B @code{pop} $B$r@k8@$7$F$$$k(B.
   $B$3$N@k8@$OI,?\$G$"$k(B.
   \E
   \BEG
   Any function defined in a module must be declared forward
   with the keyword @code{localf}.
   In the example above, @code{push} and @code{pop} are declared.
   This declaration is necessary.
   \E
   
   \BJP
   $B%b%8%e!<%k(B @code{moduleName} $B$GDj5A$5$l$?4X?t(B @code{functionName} $B$r(B
   $B%b%8%e!<%k$N30$+$i8F$V$K$O(B
        @code{moduleName.functionName($B0z?t(B1, $B0z?t(B2, ... )}
   $B$J$k7A<0$G$h$V(B.
   $B%b%8%e!<%k$NCf$+$i$O(B, $B4X?tL>$N$_$G$h$$(B.
   $B<!$NNc$G$O(B, $B%b%8%e!<%k$N30$+$i%b%8%e!<%k(B @code{stack} $B$GDj5A$5$l$?4X?t(B @code{push},
   @code{pop} $B$r8F$s$G$$$k(B.
   \E
   \BEG
   A function @code{functionName} defined in a module @code{moduleName}
   can be called by the expression
   @code{moduleName.functioName(arg1, arg2, ...)}
   out of the module.
   Inside the module, @code{moduleName.} is not necessary.
   In the example below, the functions @code{push} and @code{pop} defined
   in the module @code{stack} are called out of the module.
   \E
   
   @example
    stack.push(2);
    print( stack.pop() );
    2
   @end example
   
   \BJP
   $B%b%8%e!<%k$GMQ$$$k4X?tL>$O6I=jE*$G$"$k(B.
   $B$D$^$j%b%8%e!<%k$N30$dJL$N%b%8%e!<%k$GDj5A$5$l$F$$$k4X?tL>$HF1$8L>A0$,(B
   $BMxMQ$G$-$k(B.
   \E
   \BEG
   Any function name defined in a module is local.
   In other words, the same function name may be used out of the module
   to define a different function.
   \E
   
   \BJP
   $B%b%8%e!<%k5!G=$OBg5,LO%i%$%V%i%j$N3+H/$rA[Dj$7$F$$$k(B.
   $B%i%$%V%i%j$rI,MW$K1~$8$FJ,3d%m!<%I$9$k$K$O(B, $B4X?t(B @code{module_definedp} $B$rMQ$$$k$N$,(B
   $BJXMx$G$"$k(B.
   $B%G%^%s%I%m!<%I$O$?$H$($P<!$N$h$&$K9T$J$($PNI$$(B.
   \E
   \BEG
   The module structure of asir is introduced to develop large libraries.
   In order to load libraries on demand, the command @code{module_definedp}
   will be useful.
   The below is an example of demand loading.
   \E
   
   @example
   if (!module_definep("stack")) load("stack.rr") $
   @end example
   
   \BJP
   asir $B$G$O6I=jJQ?t$N@k8@$OITMW$G$"$C$?(B.
   $B$7$+$7%b%8%e!<%k(B stack $B$NNc$r8+$l$PJ,$+$k$h$&$K(B, @code{local A;} $B$J$k7A<0$G(B
   $B6I=jJQ?t$r@k8@$G$-$k(B.
   $B%-!<%o!<%I(B @code{local} $B$rMQ$$$k$H(B, $B@k8@5!G=$,M-8z$H$J$k(B.
   $B@k8@5!G=$rM-8z$K$9$k$H(B, $B@k8@$5$l$F$J$$JQ?t$O%m!<%I$NCJ3,$G(B
   $B%(%i!<$r5/$3$9(B.
   $BJQ?tL>$N%?%$%W%_%9$K$h$kM=4|$7$J$$%H%i%V%k$rKI$0$K$O(B,
   $B@k8@5!G=$rM-8z$K$7$F%W%m%0%i%`$9$k$N$,$h$$(B.
   \E
   \BEG
   It is not necessary to declare local variables in asir.
   As you see in the example of the stack module,
   we may declare local variables by the key word @code{local}.
   Once this key word is used, asir requires to declare all the
   variables.
   In order to avoid some troubles to develop a large libraries,
   it is recommended to use @code{local} declarations.
   \E
   
   \BJP
   $B%b%8%e!<%kFb$N4X?t$r$=$N%b%8%e!<%k$,Dj5A$5$l$kA0$K(B
   $B8F$S=P$9$h$&$J4X?t$r=q$/$H$-$K$O(B, $B$=$N4X?t$NA0$G%b%8%e!<%k$r<!$N$h$&$K(B
   $B%W%m%H%?%$%W@k8@$7$F$*$/I,MW$,$"$k(B.
   \E
   \BEG
   When we need to call a function in a module before the module is defined,
   we must make a prototype declaration as the example below.
   \E
   
   @example
   /* Prototype declaration of the module stack */
   module stack;
   localf push $
   localf pop $
   endmodule;
   
   def demo() @{
     print("----------------");
     stack.push(1);
     print(stack.pop());
     print("---------------");
   @}
   
   module stack;
     /* The body of the module stack */
   endmodule;
   @end example
   
   @table @t
   \JP @item $B;2>H(B
   \EG @item References
   @fref{module_list}, @fref{module_definedp}, @fref{remove_module}.
   @end table

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.15

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>