From d6ea92cf052ca5a8a8a88add347aefe78cb3303b Mon Sep 17 00:00:00 2001 From: dos-reis Date: Thu, 18 Oct 2007 14:02:33 +0000 Subject: Fix SF/1795259 * aggcat.spad.pamphlet (HomogeneousAggregate): Make CoercibleTo(OutputForm) if argument is of that category. (BinaryRecursiveAggregate): Weaken condition for coercion to OutputForm. (OneDimensionalArrayAggregate): Likewise. (Tuple): Likewise. (IndexedList): Likewise. * tree.spad.pamphlet: Likewise. --- src/algebra/aggcat.spad.pamphlet | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/algebra/aggcat.spad.pamphlet') diff --git a/src/algebra/aggcat.spad.pamphlet b/src/algebra/aggcat.spad.pamphlet index 1363c020..e6163807 100644 --- a/src/algebra/aggcat.spad.pamphlet +++ b/src/algebra/aggcat.spad.pamphlet @@ -86,6 +86,7 @@ Aggregate: Category == Type with ++ Those with attribute \spadatt{shallowlyMutable} allow an element ++ to be modified or updated without changing its overall value. HomogeneousAggregate(S:Type): Category == Aggregate with + if S has CoercibleTo(OutputForm) then CoercibleTo(OutputForm) if S has SetCategory then SetCategory if S has SetCategory then if S has Evalable S then Evalable S @@ -136,6 +137,7 @@ HomogeneousAggregate(S:Type): Category == Aggregate with member?(e, c) == any?(e = #1,c) x = y == size?(x, #y) and _and/[a = b for a in parts x for b in parts y] + if S has CoercibleTo(OutputForm) then coerce(x:%):OutputForm == bracket commaSeparate [a::OutputForm for a in parts x]$List(OutputForm) @@ -1502,18 +1504,18 @@ BinaryRecursiveAggregate(S:Type):Category == RecursiveAggregate S with x = value u => true member?(x,left u) or member?(x,right u) - if S has SetCategory then + if S has CoercibleTo(OutputForm) then coerce(t:%): OutputForm == empty? t => "[]"::OutputForm v := value(t):: OutputForm empty? left t => empty? right t => v - r := coerce(right t)@OutputForm + r := (right t)::OutputForm bracket ["."::OutputForm, v, r] - l := coerce(left t)@OutputForm + l := (left t)::OutputForm r := empty? right t => "."::OutputForm - coerce(right t)@OutputForm + (right t)::OutputForm bracket [l, v, r] if % has finiteAggregate then @@ -2549,6 +2551,11 @@ OneDimensionalArrayAggregate(S:Type): Category == copyInto_!(z, y, i + #x) z + if S has CoercibleTo(OutputForm) then + coerce(r:%):OutputForm == + bracket commaSeparate + [qelt(r, k)::OutputForm for k in minIndex r .. maxIndex r] + if S has SetCategory then x = y == #x ^= #y => false @@ -2556,10 +2563,6 @@ OneDimensionalArrayAggregate(S:Type): Category == not(qelt(x, i) = qelt(y, i)) => return false true - coerce(r:%):OutputForm == - bracket commaSeparate - [qelt(r, k)::OutputForm for k in minIndex r .. maxIndex r] - position(x:S, t:%, s:Integer) == n := maxIndex t s < minIndex t or s > n => error "index out of range" -- cgit v1.2.3