> The value of the expression A add B is a domain which exports those symbols > exported by A and those exports defined in B. The type of the expression A > add B is > > C with { x1: T1; ...; xn: Tn } > > where C is the type of A, and x1,...,xn are the symbols defined (using ==) > in B, whose types are T1,...,Tn, respectively.
> So, let's consider > > getit(T: Category, L: Tuple T, i: MachineInteger): T == add { > element(L, i)$Tuple(T); > } In your case A is not existing and B is "element(L, i)$Tuple(T)". The latter is *not* a definition of a any symbol. (Such definitions have the form foo(x: X, y: Y): Z == ... What you have is just a function call. The "==" sign is missing. > I think the right hand side of the "==" should export "element(L,i)$Tuple(T)", > which is of type T But "exports" must be categories. However, element(L,i)$Tuple(T) is a domain. > The following variation seems to be equivalent to my original code: > > ... == { > { element(L, i)$Tuple T } add; > } No it is not. But replace the braces by brackets and look below. Ralf ------------------------------------------------------------------- #include "aldor" #include "aldorio" macro I == MachineInteger; Object: with { object: (T: PrimitiveType, T) -> %; avail: % -> (T: PrimitiveType, T); } == add { Rep == Record(T: PrimitiveType, val: T); import from Rep; object (T: PrimitiveType, t: T) : % == per [T, t]; avail (ob: %) : (T: PrimitiveType, T) == explode rep ob; } ------------------------------------------------------------------ getit(T: Category, L: Tuple T, i: I): T == (element(L, i)$Tuple(T)) add; MyTuple(T: Category, L: Tuple T): with { new: List Object -> %; get: (i: I, %) -> getit(T, L, i); } == add { Rep == List Object; import from Rep; new(a: List Object): % == per a; get(i: I, x: %): getit(T, L, i) == { X: List Object := rep x; (U, u) == avail(X.i); u pretend getit(T, L, i); } } ------------------------------------------------------------------ import from Integer, Object, List Object, Boolean, I; t: Tuple OutputType == (Integer, Boolean); li : List Object := [object(Integer, 17), object(Boolean, true)]; m: MyTuple(OutputType, t) == new li; stdout << "==== 1 ====" << newline; b1: Boolean := getit(OutputType, t, 1) has OutputType; stdout << "getit(1) has OutputType? " << b1 << newline; if getit(OutputType, t, 1) has OutputType then { p1: getit(OutputType, t, 1) := get(1, m)$MyTuple(OutputType, t); stdout << p1 << newline; } stdout << "==== 2 ====" << newline; b2: Boolean := getit(OutputType, t, 2) has OutputType; stdout << "getit(2) has OutputType? " << b2 << newline; if getit(OutputType, t, 2) has OutputType then { p2: getit(OutputType, t, 2) := get(2, m)$MyTuple(OutputType, t); stdout << p2 << newline; } stdout << "==== END ====" << newline; -------------------------------------------------------------------- ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Aldor-combinat-devel mailing list Aldor-combinat-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/aldor-combinat-devel