On Monday, June 9, 2014 11:08:33 PM UTC+1, Nils Bruin wrote: > At any particular moment, though, an associative array has an index > universe, so as long as equality and hash are consistent within that > universe >
This seems like it would be a good solution in Sage, namely provide associative containers that participate in coercion and ensure that all elements have the same type. E.g. sage: s = SageSet([3, 8]); s # universe = ZZ {3, 8} sage: s.add(GF(5)(3)); z # coercion to universe = GF(5) {3} sage: s.add(QQ(5)) TypeError: no common canonical parent This would be consistent with our type model of always applying coercion if necessary, for example: sage: GF(5)(3) + 1 4 sage: GF(5)(3) + QQ(1) TypeError: unsupported operand parent(s) for '+': 'Finite Field of size 5' and 'Rational Field' The "coercing set" / "coercing dict" could then replace the standard Python set/dict when used on the command line. In Python code you would still default to the Python set/dict of course, just like with ZZ vs. int. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.