|
|
last edited 10 years ago by test1 |
1 2 3 | ||
Editor: Bill Page
Time: 2008/11/19 08:06:58 GMT-8 |
||
Note: |
changed: - On 02 Jan 2007 16:44:11 +0100 Francois Maltey wrote: A *.spad file can contain conditionals such as:: if R is Integer then aFunction x == a definition for integer else aFunction x == an other definition Or conditionals involving 'has'. But the function 'aFunction' must be an exported function. If 'aFunction' is a local function in the package the test is always false. So some packages export a lot of local functions, for example elemntry.spad. \begin{axiom} )sh EF \end{axiom} all the ixxx functions might be inner functions because they are defined after a conditional. The file elmentry.spad explains -- the following should be local, but are conditional I can't find any advice about it in the 30-year book. Where is the problem ? What can aldor do ? Export too much functions complicate the use of axiom. You can test this very short package for expression ------------------------------------------------------------------- \begin{spad} )abbrev package TRYCOND TryConditions TryConditions (R, F): Exports == Implementation where R : Join (OrderedSet, GcdDomain) F : Join (FunctionSpace R, TranscendentalFunctionCategory) Exports ==> with result : F -> F expResult : F -> F Implementation ==> add iResult : F -> F if R is Integer then iResult x == sin x expResult x == sin x else iResult x == cos x expResult x == cos x result x == iResult x \end{spad} test \begin{axiom} -- Expect sin : result cos result (sin x) -- Expect cos : right result (sin %i) -- Expect sin : right expResult (sin x) -- Expect cos : right expResult (sin %i) \end{axiom} Apparently this error occurs whenever a non-constant condition must be evaluated. \begin{spad} )abbrev package TRYCON2 TryCondition2 TryCondition2 (R, F): Exports == Implementation where R : Join (OrderedSet, GcdDomain) F : Join (FunctionSpace R, TranscendentalFunctionCategory) Exports ==> with result : F -> F expResult : F -> F Implementation ==> add iResult : F -> F funny:Boolean := true if funny then iResult x == sin x expResult x == sin x else iResult x == cos x expResult x == cos x result x == iResult x \end{spad} test \begin{axiom} -- Expect sin : failed result (sin x)$TryCondition2(Integer,Expression Integer) -- Expect cos : right result (sin %i)$TryCondition2(Complex Integer,Expression Complex Integer) -- Expect sin : right expResult (sin x)$TryCondition2(Integer,Expression Integer) -- Expect cos : right expResult (sin %i)$TryCondition2(Complex Integer,Expression Complex Integer) \end{axiom}
On 02 Jan 2007 16:44:11 +0100 Francois Maltey wrote:
A *.spad file can contain conditionals such as:
if R is Integer then aFunction x == a definition for integer else aFunction x == an other definition
Or conditionals involving has
.
But the function aFunction
must be an exported function.
If aFunction
is a local function in the package the test
is always false.
So some packages export a lot of local functions, for example elemntry.spad.
)sh EF
ElementaryFunction(R: Join(OrderedSet,IntegralDomain),F: Join(FunctionSpace R,RadicalCategory)) is a package constructor Abbreviation for ElementaryFunction is EF This constructor is not exposed in this frame. Issue )edit /usr/local/lib/axiom/target/x86_64-unknown-linux/../../src/algebra/EF.spad to see algebra source code for EF
------------------------------- Operations -------------------------------- acos : F -> F acosh : F -> F acot : F -> F acoth : F -> F acsc : F -> F acsch : F -> F asec : F -> F asech : F -> F asin : F -> F asinh : F -> F atan : F -> F atanh : F -> F belong? : BasicOperator -> Boolean cos : F -> F cosh : F -> F cot : F -> F coth : F -> F csc : F -> F csch : F -> F exp : F -> F iiacos : F -> F iiacosh : F -> F iiacot : F -> F iiacoth : F -> F iiacsc : F -> F iiacsch : F -> F iiasec : F -> F iiasech : F -> F iiasin : F -> F iiasinh : F -> F iiatan : F -> F iiatanh : F -> F iicos : F -> F iicosh : F -> F iicot : F -> F iicoth : F -> F iicsc : F -> F iicsch : F -> F iiexp : F -> F iilog : F -> F iisec : F -> F iisech : F -> F iisin : F -> F iisinh : F -> F iisqrt2 : () -> F iisqrt3 : () -> F iitan : F -> F iitanh : F -> F localReal? : F -> Boolean log : F -> F pi : () -> F sec : F -> F sech : F -> F sin : F -> F sinh : F -> F tan : F -> F tanh : F -> F operator : BasicOperator -> BasicOperator specialTrigs : (F,List Record(func: F,pole: Boolean)) -> Union(F,"failed")
all the ixxx functions might be inner functions because they are defined after a conditional.
I can't find any advice about it in the 30-year book.
Where is the problem ? What can aldor do ? Export too much functions complicate the use of axiom.
You can test this very short package for expression -------------------------------------------------------------------
)abbrev package TRYCOND TryConditions
TryConditions (R, F): Exports == Implementation where R : Join (OrderedSet, GcdDomain) F : Join (FunctionSpace R, TranscendentalFunctionCategory)
Exports ==> with result : F -> F expResult : F -> F
Implementation ==> add iResult : F -> F if R is Integer then iResult x == sin x expResult x == sin x else iResult x == cos x expResult x == cos x result x == iResult x
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/6890605327559572517-25px002.spad using old system compiler. TRYCOND abbreviates package TryConditions processing macro definition Exports ==> -- the constructor category processing macro definition Implementation ==> -- the constructor capsule ------------------------------------------------------------------------ initializing NRLIB TRYCOND for TryConditions compiling into NRLIB TRYCOND ****** Domain: R already in scope ****** Domain: F already in scope compiling local iResult : F -> F Time: 0.10 SEC.
compiling exported expResult : F -> F Time: 0 SEC.
compiling local iResult : F -> F Time: 0 SEC.
compiling exported expResult : F -> F Time: 0 SEC.
compiling exported result : F -> F Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |TryConditions| REDEFINED
;;; *** |TryConditions| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor TryConditions Time: 0.10 seconds
finalizing NRLIB TRYCOND Processing TryConditions for Browser database: --->-->TryConditions((result (F F))): Not documented!!!! --->-->TryConditions((expResult (F F))): Not documented!!!! --->-->TryConditions(constructor): Not documented!!!! --->-->TryConditions(): Missing Description Warning: TRYCOND;iResult has a duplicate definition in this file ------------------------------------------------------------------------ TryConditions is now explicitly exposed in frame initial TryConditions will be automatically loaded when needed from /var/zope2/var/LatexWiki/TRYCOND.NRLIB/code
test
-- Expect sin : result cos result (sin x)
![]() | (1) |
-- Expect cos : right result (sin %i)
![]() | (2) |
-- Expect sin : right expResult (sin x)
![]() | (3) |
-- Expect cos : right expResult (sin %i)
![]() | (4) |
Apparently this error occurs whenever a non-constant condition must be evaluated.
)abbrev package TRYCON2 TryCondition2
TryCondition2 (R, F): Exports == Implementation where R : Join (OrderedSet, GcdDomain) F : Join (FunctionSpace R, TranscendentalFunctionCategory)
Exports ==> with result : F -> F expResult : F -> F
Implementation ==> add iResult : F -> F funny:Boolean := true if funny then iResult x == sin x expResult x == sin x else iResult x == cos x expResult x == cos x result x == iResult x
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/6949795352273485972-25px004.spad using old system compiler. TRYCON2 abbreviates package TryCondition2 processing macro definition Exports ==> -- the constructor category processing macro definition Implementation ==> -- the constructor capsule ------------------------------------------------------------------------ initializing NRLIB TRYCON2 for TryCondition2 compiling into NRLIB TRYCON2 ****** Domain: R already in scope ****** Domain: F already in scope compiling local iResult : F -> F Time: 0.01 SEC.
compiling exported expResult : F -> F Time: 0 SEC.
compiling local iResult : F -> F Time: 0 SEC.
compiling exported expResult : F -> F Time: 0 SEC.
compiling exported result : F -> F Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |TryCondition2| REDEFINED
;;; *** |TryCondition2| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor TryCondition2 Time: 0.01 seconds
finalizing NRLIB TRYCON2 Processing TryCondition2 for Browser database: --->-->TryCondition2((result (F F))): Not documented!!!! --->-->TryCondition2((expResult (F F))): Not documented!!!! --->-->TryCondition2(constructor): Not documented!!!! --->-->TryCondition2(): Missing Description Warning: TRYCON2;iResult has a duplicate definition in this file ------------------------------------------------------------------------ TryCondition2 is now explicitly exposed in frame initial TryCondition2 will be automatically loaded when needed from /var/zope2/var/LatexWiki/TRYCON2.NRLIB/code
test
-- Expect sin : failed result (sin x)$TryCondition2(Integer,Expression Integer)
![]() | (5) |
-- Expect cos : right result (sin %i)$TryCondition2(Complex Integer,Expression Complex Integer)
![]() | (6) |
-- Expect sin : right expResult (sin x)$TryCondition2(Integer,Expression Integer)
![]() | (7) |
-- Expect cos : right expResult (sin %i)$TryCondition2(Complex Integer,Expression Complex Integer)
![]() | (8) |