Martin, > The only slight awkwardness I can imagine is as follows: If I export, say, in > Polynomial > > coefficientRing: () -> Ring > > then the result of baseRing will be a Ring, and may have "forgotten" all the > other categories it possibly satisfies. Hm, it seems I will never understand > "has" completely - Ralf, could you remind me why the following output is > produced by Aldor?
Maybe you google for something like +"static type" +"dynamic type" +aldor Christian's remarks should be correct. It is as simple as this: with "has" you refer to all the exports of a domain. So if A: with {foo: () -> ()} == add {foo(): () == {}} B: with {bar: () -> ()} == A add {bar(): () == {}} then B (statically) only exports bar, but if you look at the right hand side of the definition of B then there is a (anonymous) domain A add {bar(): () == {}} which is of type with { foo: () -> () bar: () -> () } and all this can be seen by "has" from B, too. So B has with {foo: () -> ()} returns true. I don't say that I like that since one can easily produce code that looks typesafe but is completely wrong (see end of mail). Note that suddenly, -1 is a member of NNI. Ralf ---BEGIN HasSemantics.as #include "aldor" #include "aldorio" NNI: with { +: (%, %) -> %; coerce: Integer -> %; <<: (TextWriter, %) -> TextWriter; } == Integer add { Rep == Integer; import from Rep; coerce(x: Integer): % == per x; (p: TextWriter) << (x: %): TextWriter == p << rep x; } main(): () == { import from Integer; stdout << "NNI has with -: % -> % ---- "; stdout << (NNI has with {-:%->%}) << newline; a: NNI := 1::NNI; if NNI has with {-:%->%} then { b: NNI := -a; stdout << "-([EMAIL PROTECTED]) = " << b << newline; } stdout << "INT has IntegerType --- "; stdout << (Integer has IntegerType) << newline; stdout << "NNI has IntegerType --- "; stdout << (NNI has IntegerType) << newline; stdout << "NNI has OrderedArithmeticType --- "; stdout << (NNI has OrderedArithmeticType) << newline; stdout << "NNI has with <: (%,%) -> Boolean ---- "; stdout << (NNI has with {<:(%,%)->Boolean}) << newline; } main(); ---END HasSemantics.as --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---