login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Conditional for inner functions in a package.

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.

fricas
(1) -> )sh EF
ElementaryFunction(R: Join(Comparable,IntegralDomain),F: Join(FunctionSpace(R),RadicalCategory)) is a package constructor Abbreviation for ElementaryFunction is EF This constructor is not exposed in this frame. ------------------------------- 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.

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 -------------------------------------------------------------------

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 iResult x == cos x expResult x == cos x if R is Integer then iResult x == sin x expResult x == sin x result x == iResult x
spad
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/6806777473810003701-25px002.spad
      using old system compiler.
   TRYCOND abbreviates package TryConditions 
------------------------------------------------------------------------
   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.02 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.02 seconds
finalizing NRLIB TRYCOND Processing TryConditions for Browser database: --->-->TryConditions(constructor): Not documented!!!! --->-->TryConditions((result (F F))): Not documented!!!! --->-->TryConditions((expResult (F F))): Not documented!!!! --->-->TryConditions(): Missing Description ; compiling file "/var/aw/var/LatexWiki/TRYCOND.NRLIB/TRYCOND.lsp" (written 10 OCT 2024 12:39:43 PM):
; wrote /var/aw/var/LatexWiki/TRYCOND.NRLIB/TRYCOND.fasl ; compilation finished in 0:00:00.008 ------------------------------------------------------------------------ TryConditions is now explicitly exposed in frame initial TryConditions will be automatically loaded when needed from /var/aw/var/LatexWiki/TRYCOND.NRLIB/TRYCOND

test

fricas
-- Expect sin : right
result (sin x)

\label{eq1}\sin \left({\sin \left({x}\right)}\right)(1)
Type: Expression(Integer)
fricas
-- Expect cos : result sin  
result (sin %i)
There are 1 exposed and 1 unexposed library operations named result having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op result to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named result with argument type(s) Expression(Complex(Integer))
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.




  Subject:   Be Bold !!
  ( 15 subscribers )  
Please rate this page: