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

Edit detail for SandBoxSpeciesCategory revision 2 of 4

1 2 3 4
Editor: Bill Page
Time: 2008/11/12 13:27:45 GMT-8
Note: using coerce (almost) works in OpenAxiom

changed:
-       retract: % -> SpeciesCategory L
       coerce: % -> SpeciesCategory L

changed:
-   retract(s: %): SpeciesCategory L == s pretend SpeciesCategory(L)
   coerce(s: %): SpeciesCategory L == s pretend SpeciesCategory(L)

added:
On Tue, Nov 11, 2008 at 7:38 PM Waldek Hebisch wrote:

Martin wrote::

 I did the following experiment.

 In FriCAS, I get an error when I uncomment the line containing the Rep in
 SPECIES.  This does not happen in Open-Axiom.  Otherwise, it compiles and I can
 do

 (1) -> S1 := 1$Species INT

    (1)  "CharacteristicSpecies(1)"

                                            Type: Species(Integer)
 (2) -> S2 := S1::SpeciesCategory INT

    You cannot use SpeciesCategory(Integer) or any other category in a
       target, coercion, or package-call context.


I am slightly suprized that the file compiles and is doing someting
sensible.

This is message S2IE0014 (normal tactic when looking at simlar cases
is to search src/share/doc/msgs/s2-us.msgs to find message id and
then grep sources to find where the id is used).  It appears twice
in i-spec1.boot::

  grep -n S2IE0014 *
  i-spec1.boot:383:  categoryForm?(m) => throwKeyedMsg("S2IE0014",[m])
  i-spec1.boot:408:  categoryForm?(m) => throwKeyedMsg("S2IE0014",[m])

Try commenting out the checks.

\begin{boot}
import i_-analy
namespace BOOT

--% Handlers for TARGET

upTARGET t ==
  -- Evaluates the rhs to a mode,which is used as the target type for
  -- the lhs.
  t isnt [op,lhs,rhs] => nil
  -- do not (yet) support local variables on the rhs
  (not $genValue) and or/[CONTAINED(var,rhs) for var in $localVars] =>
    keyedMsgCompFailure("S2IC0010",[rhs])
  $declaredMode: local := NIL
  m:= evaluateType unabbrev rhs
  not isLegitimateMode(m,NIL,NIL) => throwKeyedMsg("S2IE0004",[m])
  --categoryForm?(m) => throwKeyedMsg("S2IE0014",[m])
  $declaredMode:= m
  not atom(lhs) and putTarget(lhs,m)
  ms := bottomUp lhs
  first ms ^= m =>
    throwKeyedMsg("S2IC0011",[first ms,m])
  putValue(op,getValue lhs)
  putModeSet(op,ms)

--% Handlers for COERCE

upCOERCE t ==
  -- evaluate the lhs and then tries to coerce the result to the
  -- mode which is the rhs.
  -- previous to 5/16/89, this had the same semantics as
  --    (lhs@rhs) :: rhs
  -- this must be made explicit now.
  t isnt [op,lhs,rhs] => nil
  $useConvertForCoercions : local := true
  -- do not (yet) support local variables on the rhs
  (not $genValue) and or/[CONTAINED(var,rhs) for var in $localVars] =>
    keyedMsgCompFailure("S2IC0006",[rhs])
  $declaredMode: local := NIL
  m := evaluateType unabbrev rhs
  not isLegitimateMode(m,NIL,NIL) => throwKeyedMsg("S2IE0004",[m])
  --categoryForm?(m) => throwKeyedMsg("S2IE0014",[m])
  $declaredMode:= m
  -- 05/16/89 (RSS) following line commented out to give correct
  -- semantic difference between :: and @
  bottomUp lhs
  type:=evalCOERCE(op,lhs,m)
  putModeSet(op,[type])
\end{boot}


changed:
-S2 := retract(S1)
S2 := coerce(S1)@SpeciesCategory(Integer)

added:
S3 := S1::SpeciesCategory(Integer)
structures([1])$S3
structures([1,2,3])$S3

spad
)abb category SPECCAT SpeciesCategory
SpeciesCategory(L: SetCategory): Category == SetCategory with
       structures: Set L -> List %
       name: () -> String
)abb domain CHARSPEC CharacteristicSpecies CharacteristicSpecies(L: SetCategory, n: Integer): SpeciesCategory L == add Rep := Set L
coerce(t: %): OutputForm == coerce(t)$Rep
structures s == if #s = n then [s] else []
name () == concat ["CharacteristicSpecies(", string n, ")"]
)abb domain SPECIES Species Species(L: SetCategory): Ring with coerce: % -> SpeciesCategory L == add Rep := SpeciesCategory L
coerce(s: %): OutputForm == S := s pretend SpeciesCategory(L) name()$S::OutputForm
coerce(s: %): SpeciesCategory L == s pretend SpeciesCategory(L)
0 == CharacteristicSpecies(L, 0) pretend Rep 1 == CharacteristicSpecies(L, 1) pretend Rep
spad
   Compiling OpenAxiom source code from file 
      /var/zope2/var/LatexWiki/32396914629305039-25px001.spad using 
      Spad compiler.
   SPECCAT abbreviates category SpeciesCategory 
------------------------------------------------------------------------
   initializing NRLIB SPECCAT for SpeciesCategory 
   compiling into NRLIB SPECCAT 
Time: 0 SEC.
finalizing NRLIB SPECCAT Processing SpeciesCategory for Browser database: --->-->SpeciesCategory((structures ((List %) (Set L)))): Not documented!!!! --->-->SpeciesCategory((name ((String)))): Not documented!!!! --->-->SpeciesCategory(constructor): Not documented!!!! --->-->SpeciesCategory(): Missing Description ------------------------------------------------------------------------ SpeciesCategory is now explicitly exposed in frame initial SpeciesCategory will be automatically loaded when needed from /var/zope2/var/LatexWiki/SPECCAT.NRLIB/code.o
CHARSPEC abbreviates domain CharacteristicSpecies Adding Integer modemaps ------------------------------------------------------------------------ initializing NRLIB CHARSPEC for CharacteristicSpecies compiling into NRLIB CHARSPEC Adding $ modemaps Adding L modemaps Adding Rep modemaps Adding OutputForm modemaps compiling exported coerce : % -> OutputForm Time: 0.08 SEC.
Adding List $ modemaps Adding Set L modemaps compiling exported structures : Set L -> List % Adding Boolean modemaps Time: 0.02 SEC.
Adding String modemaps compiling exported name : () -> String Adding List String modemaps Time: 0.01 SEC.
(time taken in buildFunctor: 0) Time: 0 SEC.
Cumulative Statistics for Constructor CharacteristicSpecies Time: 0.11 seconds
finalizing NRLIB CHARSPEC Processing CharacteristicSpecies for Browser database: --->-->CharacteristicSpecies(): Missing Description ------------------------------------------------------------------------ CharacteristicSpecies is now explicitly exposed in frame initial CharacteristicSpecies will be automatically loaded when needed from /var/zope2/var/LatexWiki/CHARSPEC.NRLIB/code.o
SPECIES abbreviates domain Species ------------------------------------------------------------------------ initializing NRLIB SPECIES for Species compiling into NRLIB SPECIES Adding $ modemaps Adding L modemaps Adding OutputForm modemaps compiling exported coerce : % -> OutputForm Adding S modemaps Adding String modemaps Time: 0.08 SEC.
compiling exported coerce : % -> SpeciesCategory L SPECIES;coerce;$Sc;2 is replaced by s Time: 0 SEC.
compiling exported Zero : () -> % Adding Rep modemaps Adding Integer modemaps Time: 0 SEC.
compiling exported One : () -> % Adding Rep modemaps Adding Integer modemaps Time: 0 SEC.
(time taken in buildFunctor: 1) Time: 0.01 SEC.
Warnings: [1] Zero: pretend Rep -- should replace by @ [2] One: pretend Rep -- should replace by @
Cumulative Statistics for Constructor Species Time: 0.09 seconds
finalizing NRLIB SPECIES Processing Species for Browser database: --->-->Species((coerce ((SpeciesCategory L) %))): Not documented!!!! --->-->Species(constructor): Not documented!!!! --->-->Species(): Missing Description ------------------------------------------------------------------------ Species is now explicitly exposed in frame initial Species will be automatically loaded when needed from /var/zope2/var/LatexWiki/SPECIES.NRLIB/code.o

On Tue, Nov 11, 2008 at 7:38 PM Waldek Hebisch wrote:

Martin wrote:

 I did the following experiment.

 In FriCAS, I get an error when I uncomment the line containing the Rep in
 SPECIES.  This does not happen in Open-Axiom.  Otherwise, it compiles and I can
 do

 (1) -> S1 := 1$Species INT

    (1)  "CharacteristicSpecies(1)"

                                            Type: Species(Integer)
 (2) -> S2 := S1::SpeciesCategory INT

    You cannot use SpeciesCategory(Integer) or any other category in a
       target, coercion, or package-call context.

I am slightly suprized that the file compiles and is doing someting sensible.

This is message S2IE0014 (normal tactic when looking at simlar cases is to search src/share/doc/msgs/s2-us.msgs to find message id and then grep sources to find where the id is used). It appears twice in i-spec1.boot:

  grep -n S2IE0014 *
  i-spec1.boot:383:  categoryForm?(m) => throwKeyedMsg("S2IE0014",[m])
  i-spec1.boot:408:  categoryForm?(m) => throwKeyedMsg("S2IE0014",[m])

Try commenting out the checks.

boot
import i_-analy
namespace BOOT
--% Handlers for TARGET
upTARGET t == -- Evaluates the rhs to a mode,which is used as the target type for -- the lhs. t isnt [op,lhs,rhs] => nil -- do not (yet) support local variables on the rhs (not $genValue) and or/[CONTAINED(var,rhs) for var in $localVars] => keyedMsgCompFailure("S2IC0010",[rhs]) $declaredMode: local := NIL m:= evaluateType unabbrev rhs not isLegitimateMode(m,NIL,NIL) => throwKeyedMsg("S2IE0004",[m]) --categoryForm?(m) => throwKeyedMsg("S2IE0014",[m]) $declaredMode:= m not atom(lhs) and putTarget(lhs,m) ms := bottomUp lhs first ms ^= m => throwKeyedMsg("S2IC0011",[first ms,m]) putValue(op,getValue lhs) putModeSet(op,ms)
--% Handlers for COERCE
upCOERCE t == -- evaluate the lhs and then tries to coerce the result to the -- mode which is the rhs. -- previous to 5/16/89, this had the same semantics as -- (lhs@rhs) :: rhs -- this must be made explicit now. t isnt [op,lhs,rhs] => nil $useConvertForCoercions : local := true -- do not (yet) support local variables on the rhs (not $genValue) and or/[CONTAINED(var,rhs) for var in $localVars] => keyedMsgCompFailure("S2IC0006",[rhs]) $declaredMode: local := NIL m := evaluateType unabbrev rhs not isLegitimateMode(m,NIL,NIL) => throwKeyedMsg("S2IE0004",[m]) --categoryForm?(m) => throwKeyedMsg("S2IE0014",[m]) $declaredMode:= m -- 05/16/89 (RSS) following line commented out to give correct -- semantic difference between :: and @ bottomUp lhs type:=evalCOERCE(op,lhs,m) putModeSet(op,[type])
boot
Value = NIL
The source file 6792422082361307195-25px002.clisp is not found.
Value = T

axiom
S1 := 1$Species INT
LatexWiki Image(1)
Type: Species Integer
axiom
S2 := coerce(S1)@SpeciesCategory(Integer)
LatexWiki Image(2)
Type: SpeciesCategory? Integer
axiom
structures([1])$S2
LatexWiki Image(3)
Type: List CharacteristicSpecies?(Integer,1)
axiom
structures([1,2,3])$S2
LatexWiki Image(4)
Type: List CharacteristicSpecies?(Integer,1)
axiom
S3 := S1::SpeciesCategory(Integer)
LatexWiki Image(5)
Type: SpeciesCategory? Integer
axiom
structures([1])$S3
>> System error: Caught fatal error [memory may be damaged]