[Aldor-l] Lists of things not being domains or values of domains [was: Re: [Aldor-combinat-devel] Small Problem with List of functions.]
Christian Aistleitner
tmgisi at gmx.at
Fri Oct 13 04:06:32 EDT 2006
Hello Martin,
I CC’d to aldor-l as this might be a common pitfall.
Just for introduction to the aldor-l people:
- LabelType is just some Category.
- CombinatorialSpecies is a Category taking a LabelType as parameter.
On Thu, 12 Oct 2006 17:16:29 +0200, Martin Rubey
<martin.rubey at univie.ac.at> wrote:
> macro CC == (T: LabelType) -> CombinatorialSpecies(T);
> import from List CC;
> l: List CC := [];
>
> produces a segfault.
>
> Did I overlook something?
It occurred to me, that passing things not being a domain or value of a
domain sometimes causes problems for the Aldor compiler -- Especially when
used as parameter to a function (In your case: List. But “Record” is
another example frequently causing trouble).
I guess this issue causes your segfault.
Consider
#include "combinat"
#include "aldorio"
Wrapper: with {
coerce: ( ( L: LabelType ) -> ( CombinatorialSpecies L ) ) -> %;
coerce: % -> ( ( L: LabelType ) -> ( CombinatorialSpecies L ) );
} == add {
coerce( f: ( L: LabelType ) -> ( CombinatorialSpecies L ) ): % == {
f pretend %
}
coerce( w: % ): ( ( L: LabelType ) -> ( CombinatorialSpecies L ) ) == {
w pretend ( ( L: LabelType ) -> ( CombinatorialSpecies L ) );
}
}
import from List Wrapper;
[]$(List Wrapper);
-- some more code to actually generate a non-empty List of Wrapper
import from Wrapper;
import from MachineInteger;
import from Trace;
testFunc( L: LabelType ): CombinatorialSpecies L == { EmptySetSpecies L };
testList: List Wrapper := [ coerce testFunc ];
funcFromList: ( L: LabelType ) -> CombinatorialSpecies( L ) := coerce
( testList . 1 );
stdout << ( name ( funcFromList MachineInteger ) ) << newline;
. This “solution” compiles ( I used
/opt/aldor/bin/aldor -M no-abbrev -C args=-Wopts=-m32 -Fx -Y
/sources/aldor/aldor-combinat/combinat/trunk/combinat/lib/ -I
/sources/aldor/aldor-combinat/combinat/trunk/combinat/include/ -l
combinatd -l algebrad -l aldord -DDEBUG test.as
to compile the code
) and runs without any problems:
____________________________________________
tmgisi at spencer
cwd: ~/aldor
$ ./test
EmptySetSpecies(MachineInteger)
I just wrapped your
( L: LabelType ) -> L
into a proper domain.
Of course, it's a pain to wrap and unwrap things, but you can at least get
your code to run that way.
--
Kind regards,
Christian
More information about the Aldor-l
mailing list