How do I programm such mutual recursion in SPAD?
BTW, in fact I want a global store (here represented by
h: XHashTable(String, ConstructorData) := empty()
which will be filled whenever some data is computed. Otherwise
ConstructorDataBase should simply serve as cache.
Other ways how to implement that idea.
Maybe, instead of passing ConstructorData to my functions, I must pass
ConstructorDataBase and name of the constructor.
Ralf
(1) -> )co foo.spad
Compiling FriCAS source code from file
/home/hemmecke/backup/git/fricas/src/doc/foo.spad using old
system compiler.
CONDB abbreviates package ConstructorDataBase
------------------------------------------------------------------------
initializing NRLIB CONDB for ConstructorDataBase
compiling into NRLIB CONDB
****** comp fails at level 1 with expression: ******
(|ConstructorData|)
****** level 1 ******
$x:= ConstructorData
$m:= (Type)
$f:=
((((|data| #) (|#| #) (= #) (|any?| #) ...)))
>> Apparent user error:
unspecified error
If I reorder the constructors (first ConstructorData, then
ConstructorDataBas), then I get this:
(1) -> )co foo.spad
Compiling FriCAS source code from file
/home/hemmecke/backup/git/fricas/src/doc/foo.spad using old
system compiler.
CONDATA abbreviates domain ConstructorData
------------------------------------------------------------------------
initializing NRLIB CONDATA for ConstructorData
compiling into NRLIB CONDATA
processing macro definition Rep ==> String
compiling exported computeConstructorData : String -> $
CONDATA;computeConstructorData;S$;1 is replaced by str
Time: 0.01 SEC.
compiling exported getConstructorData : String -> $
****** comp fails at level 1 with expression: ******
error in function getConstructorData
(((|Sel| |ConstructorDataBase| |constructorData|) |s|))
****** level 1 ******
$x:= ((Sel ConstructorDataBase constructorData) s)
$m:= $
$f:=
((((|s| # #) (|#| #) (< #) (<= #) ...)))
>> Apparent user error:
ConstructorDataBase
is an unknown mode
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
)abbrev package CONDB ConstructorDataBase
ConstructorDataBase: with
constructorData: String -> ConstructorData
== add
h: XHashTable(String, ConstructorData) := empty()
constructorData(con: String): ConstructorData ==
key?(con, h) => h.con
h.con := computeConstructorData(con)$ConstructorData
-------------------------------------------------------------------
)abbrev domain CONDATA ConstructorData
ConstructorData: with
computeConstructorData: String -> %
getConstructorData: String -> %
== add
Rep ==> String
computeConstructorData(str: String): % == str pretend %
getConstructorData(s: String): % == constructorData(s)$ConstructorDataBase