|
|
last edited 11 years ago by test1 |
1 2 3 4 5 6 7 8 9 10 11 12 | ||
Editor: Bill Page
Time: 2008/05/13 08:14:12 GMT-7 |
||
Note: scope issues |
added:
Ralf wrote:
Ooops, what in would be illegal? I just had to replace
(as I said) the braces by parentheses, since parens are
used to group sequences of commands. (Same as braces in
Aldor.)
\begin{spad}
)abbrev domain AAA Aaa
Aaa: with
bar: Integer -> Integer
== add
(x: Integer := 4; y: Integer := 3)
bar(a: Integer): Integer == x + a + z
z: Integer := 3 + y
\end{spad}
But this works?
\begin{spad}
)abbrev domain AAA Aaa
Aaa: with
bar: Integer -> Integer
== add
(x: Integer := 4; y: Integer := 3)
z: Integer := 3 + y
bar(a: Integer): Integer == x + a + z
\end{spad}
j is referenced out of scope
axiomfor i in 1..5 repeat j:Integer := i^2 output(i::OutputForm)$OutputPackage 1 2 3 4 5
axiomoutput(j::OutputForm)$OutputPackage 25
The code above returns an error in OpenAxiom? 1.2.0 (Revision >= 563).
It sould be written like this:
axiomj: Integer
axiomfor i in 1..5 repeat j := i^2 output(i::OutputForm)$OutputPackage 1 2 3 4 5
axiomoutput(j::OutputForm)$OutputPackage 25
Oddly, using j out of scope is also allowed in Aldor:
aldor#pile #include "axiom" import from PositiveInteger CheckScope1(): with checkscope1: () -> PositiveInteger == add checkscope1():PositiveInteger == for i in 1..5 repeat j:PositiveInteger := i^2 --output(i::OutputForm)$OutputPackage --output(j::OutputForm)$OutputPackage j
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/8452782754204589047-25px003.as using AXIOM-XL compiler and options -O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra Use the system command )set compiler args to change these options. #1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL' Compiling Lisp source code from file ./8452782754204589047-25px003.lsp Issuing )library command for 8452782754204589047-25px003 Reading /var/zope2/var/LatexWiki/8452782754204589047-25px003.asy CheckScope1 is now explicitly exposed in frame initial CheckScope1 will be automatically loaded when needed from /var/zope2/var/LatexWiki/8452782754204589047-25px003
axiomcheckscope1()
(1) |
aldor#pile #include "axiom" import from PositiveInteger CheckScope2(): with checkscope2: () -> PositiveInteger == add checkscope2():PositiveInteger == local j:PositiveInteger for i in 1..5 repeat j := i^2 --output(i::OutputForm) --output(j::OutputForm)$OutputPackage j
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/8264748852590484820-25px005.as using AXIOM-XL compiler and options -O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra Use the system command )set compiler args to change these options. #1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL' Compiling Lisp source code from file ./8264748852590484820-25px005.lsp Issuing )library command for 8264748852590484820-25px005 Reading /var/zope2/var/LatexWiki/8264748852590484820-25px005.asy CheckScope2 is now explicitly exposed in frame initial CheckScope2 will be automatically loaded when needed from /var/zope2/var/LatexWiki/8264748852590484820-25px005
axiomcheckscope2()
(2) |
Ralf wrote:
Ooops, what in would be illegal? I just had to replace (as I said) the braces by parentheses, since parens are used to group sequences of commands. (Same as braces in Aldor.)
spad)abbrev domain AAA Aaa Aaa: with bar: Integer -> Integer == add (x: Integer := 4; y: Integer := 3) bar(a: Integer): Integer == x + a + z z: Integer := 3 + y
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/2292316700013189339-25px007.spad using old system compiler. AAA abbreviates domain Aaa ------------------------------------------------------------------------ initializing NRLIB AAA for Aaa compiling into NRLIB AAA compiling exported bar : Integer -> Integer ****** comp fails at level 2 with expression: ****** error in function bar (+ (+ |x| |a|) | << z >> |) ****** level 2 ****** $x:= z $m:= $EmptyMode $f:= ((((|a| # #) (|y| # #) (|x| # #) (* # # #) ...))) >> Apparent user error: cannot compile (+ (+ x a) z)
But this works?
spad)abbrev domain AAA Aaa Aaa: with bar: Integer -> Integer == add (x: Integer := 4; y: Integer := 3) z: Integer := 3 + y bar(a: Integer): Integer == x + a + z
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/5820990303886118597-25px008.spad using old system compiler. AAA abbreviates domain Aaa ------------------------------------------------------------------------ initializing NRLIB AAA for Aaa compiling into NRLIB AAA compiling exported bar : Integer -> Integer Time: 0 SEC. (time taken in buildFunctor: 0) ;;; *** |Aaa| REDEFINED ;;; *** |Aaa| REDEFINED Time: 0 SEC. Cumulative Statistics for Constructor Aaa Time: 0 seconds finalizing NRLIB AAA Processing Aaa for Browser database: --->-->Aaa((bar ((Integer) (Integer)))): Not documented!!!! --->-->Aaa(constructor): Not documented!!!! --->-->Aaa(): Missing Description ------------------------------------------------------------------------ Aaa is now explicitly exposed in frame initial Aaa will be automatically loaded when needed from /var/zope2/var/LatexWiki/AAA.NRLIB/code