#10963: More functorial constructions
-------------------------------------+-------------------------------------
Reporter: nthiery | Owner: stumpc5
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.1
Component: categories | Resolution:
Keywords: days54 | Merged in:
Authors: Nicolas M. Thiéry | Reviewers: Simon King, Frédéric
Report Upstream: N/A | Chapoton
Branch: | Work issues:
public/ticket/10963 | Commit:
Dependencies: #11224, #8327, | 8045aa4a4b7ada735b3eb6055382f9b341a39f1e
#10193, #12895, #14516, #14722, | Stopgaps:
#13589, #14471, #15069, #15094, |
#11688, #13394, #15150, #15506 |
-------------------------------------+-------------------------------------
Comment (by vbraun):
Replying to [comment:395 nbruin]:
> We don't! We normally pass around the values that are bound to them.
Thats what I meant by "them", sorry for being unclear. My point is not so
much about what exactly is passed, but that there is nothing passed,
referenced, imported, or inherited from at all:
{{{
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"
sage: P = Parent(category=Cs().Finite())
sage: P.is_finite() # What is this I don't even
}}}
Nowhere does the source of `Sets.Finite` refer to `Cs.Finite` or vice
versa. By the normal mental model of Python code (principle of least
astonishment), that ought to mean that the implementations are
independent. The only thing that ties them together ultimately is that a
substring of the type name matches. For example the following would make
me much happier since it makes the dependence visible:
{{{
sage: class Cs(Category):
....: def super_categories(self):
....: return [Sets()]
....: class Finite_or_any_other_name(Sets.Finite):
....: class ParentMethods:
....: def foo(self):
....: print "I am a method on finite C's"
sage: P = Parent(category=Cs().Finite_or_any_other_name())
sage: P.is_finite() # obviously comes from Sets.Finite
}}}
Or, even better, with stand-alone axiom objects either using a
`@require_axiom(Finite)` decorator or class syntax if you prefer:
{{{
sage: class Cs(Category):
....: class Finite_or_any_other_name(axioms.Finite):
....: class ParentMethods:
....: def foo(self):
....: print "I am a method on finite C's"
}}}
You could argue that the `ParentMethods` / `ElementMethods` are already
precedent for magic attribute names that violate the usual python mental
model. Thats true, but a) I wasn't asked when they were introduced and b)
there are only two magic names that are ubiquitous in every category
source. So it is still kind of obvious from the source code. But if you
end up with precisely two categories that have a ''Flasque'' subcategory,
say, then it is going to be very confusing.
--
Ticket URL: <http://trac.sagemath.org/ticket/10963#comment:396>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.