First of all, Nicolas has done a lot of work on this ticket and I very much 
agree with his goal of providing a mixin framework for categories (called 
"axioms" on the ticket) so that you don't have to, say, separately write a 
FiniteCategory for each Category. Its also the hardest for me to say "No" 
since I generally want to make progress and push things forward. But I 
really feel uncomfortable with the syntax which IMHO deviates too much (and 
unnecessarily so) from normal Python.

I also think we agree that the implementation where a recursive computation 
is done on startup is not ideal. Relatively simple implementation mistakes 
in new category/axioms end up with an infinite recursion on startup, which 
I think is rather unhelpful for developers. There is also no way to doctest 
this recursion beyond "sage manages to start up". This is related to the 
fact that adding an assertion in the wrong place can easily lead to 
hard-to-debug infinite recursions, as Nicolas already mentioned. But then, 
this could all be improved on a later ticket.

What really bothers me with the ticket is the reliance on implicit magic 
over explicitly specifying relations between categories. From the ticket, 
this example:

sage: class Cs(Category):
....:     def super_categories(self):
....:         return [Sets()]
....:     class Finite(CategoryWithAxiom):
....:         class ParentMethods:
....:             def foo(self):
....:                 print "I am a method on finite C's"

implements

sage: P = Parent(category=Cs().Finite())
sage: P.foo()           # ok, nice
I am a method on finite C's
sage: P.is_finite()     # Where does that come from?
True

The theory here is that Sets defines a Finite axiom, and by some metaclass 
magic the inner class Cs.Finite ends up being a subcategory of Sets.Finite. 
But none of that is apparent from reading the code, you can pretty much 
only figure it out through reading the sage/categories/sets_cat.py or 
introspection if your Sage install manages to start up. It is well 
documented, which is nice but IMHO it would be even nicer if you could 
understand what is going on by just reading the code. Nicolas thinks this 
amount of breverity is a desirable feature, and I think we should make 
Cs.Finite be explicit about which axiom it implements (and, therefore, not 
require that it is named Cs.Finite if you don't want to). We've explored 
various ways to implement this syntax, either through inheritance or a 
class attribute, but Nicolas doesn't like any.

Nicolas keeps saying that we can change the syntax later, but I think that 
should be done right or not at all on this ticket (one can easily implement 
the axiom functionality without introducing the subclass syntax).

-- 
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.

Reply via email to