=================================================================== RCS file: /home/cvs/OpenXM/src/asir-doc/parts/asir.texi,v retrieving revision 1.14 retrieving revision 1.18 diff -u -p -r1.14 -r1.18 --- OpenXM/src/asir-doc/parts/asir.texi 2003/12/21 17:36:29 1.14 +++ OpenXM/src/asir-doc/parts/asir.texi 2005/07/25 12:23:05 1.18 @@ -1,4 +1,4 @@ -@comment $OpenXM: OpenXM/src/asir-doc/parts/asir.texi,v 1.13 2003/12/20 13:38:44 ohara Exp $ +@comment $OpenXM: OpenXM/src/asir-doc/parts/asir.texi,v 1.17 2004/07/10 05:50:57 takayama Exp $ \BJP @node ユーザ言語 Asir,,, Top @chapter ユーザ言語 Asir @@ -1451,8 +1451,53 @@ After @samp{|} one can append any number of options se [100] xxx(1,2,x^2-1,[1,2,3]|proc=1,index=5); @end example +\BJP +さらに, オプションを @code{key1=value1,key2=value2,...} のように +@samp{,} で区切って渡す代わりに, 特別なキーワード @code{option_list} +とオプションリスト @code{[["key1",value1],["key2",value2],...]} +を用いて渡すことも可能である. +\E +\BEG +Optinal arguments may be given as a list +with the key word @code{option_list} +as +@code{option_list=[["key1",value1],["key2",value2],...]}. +It is equivalent to pass the optional arguments as +@code{key1=value1,key2=value2,...}. +\E +@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 + \BJP +特に, 引数なしの @code{getopt()} はオプションリストを返すので, +オプションをとる関数から, オプションをとる関数を呼び出すときには有用である. +\E +\BEG +Since @code{getopt()} returns an option list, +the optional argument @code{option_list=...} is useful when +we call functions with optional arguments from +a function with optional arguments to pass +the all optional parameters. +\E + +@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 + +\BJP @node モジュール,,, ユーザ定義函数の書き方 @subsection モジュール \E @@ -1587,7 +1632,7 @@ The below is an example of demand loading. \E @example -if (!module_definep("stack")) load("stack.rr") $ +if (!module_definedp("stack")) load("stack.rr") $ @end example \BJP @@ -1637,6 +1682,38 @@ def demo() @{ module stack; /* The body of the module stack */ endmodule; +@end example + +\BJP +モジュールの中からトップレベルで定義されている関数を呼ぶには, +下の例のように @code{::} を用いる. +\E +\BEG +In order to call functions defined in the top level from the inside +of a module, we use @code{::} as in the example below. +\E +@example +def afo() @{ + S = "afo, afo"; + return S; +@} +module abc; +localf foo,afo $ + +def foo() @{ + G = ::afo(); + return G; +@} +def afo() @{ + return "afo, afo in abc"; +@} +endmodule; +end$ + +[1200] abc.foo(); +afo, afo +[1201] abc.afo(); +afo, afo in abc @end example @table @t