#14912: UniqueRepresentation tutorial could use more love
--------------------------------------------+--------------------
Reporter: darij | Owner:
Type: defect | Status: new
Priority: major | Milestone:
Component: documentation | Resolution:
Keywords: documentation, structure | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Dependencies:
Stopgaps: |
--------------------------------------------+--------------------
Comment (by SimonKing):
Replying to [comment:11 darij]:
> I fear the doc of {{{_clear_cache_()}}} is beyound my comprehension...
Is the difference just in the fact that a {{{__classcall_private__}}}
method will not be inherited by subclasses while a {{{__classcall__}}}
will be? (But I thought all methods would be inherited by subclasses?)
Your question really is about
`sage.misc.classcall_metaclass.ClasscallMetaclass`, which is where methods
such as `__classcall__`, `__classget__`, `__classcontains__` and
`__classcall_private__` take effect.
Here, we look at
`sage.misc.classcall_metaclass.ClasscallMetaclass.__call__`, which
implements the creation of instances of a class. Of course, if a class C
defines `__classcall_private__` and a class D inherits from C, then D also
has a `__classcall_private__` method. However, you can find this method in
`C.__dict__` but not in `D.__dict__`.
And the rule is: If an instance of a class (here: C or D) is created by
calling `ClasscallMetaclass.__class__`, then
* it will be checked whether the class has a `__classcall_private__` in
its own `__dict__`. If this is the case, then `__classcall_private__` will
be called. Otherwise,
* it is checked whether the class has a `__classcall__` method (which is
not necessarily in `__dict__`, as it could be inherited from a base
class). If this is the case, then `__classcall__` will be called.
I just said "we look at `ClasscallMetaclass.__call__`". Well, in fact we
look at `CLasscallMetaclass.__cinit__`, because this is where the choice
between `__classcall__` and `__classcall_private__` is made.
What does all this mean for this ticket?
Question: Do you think it would be enough to state in the documentation of
`CachedRepresentation` that it has the `ClasscallMetaclass` and that it
provides a `__classcall__` implementing the cache, and that one can use
`__classcall_private__` or `__classcall__` as explained in the docs of
`ClasscallMetaclass` to overload the default way of caching?
Or I guess it would still be a good idea to have examples in place,
without the need to read the `ClasscallMetaclass` docs...
--
Ticket URL: <http://trac.sagemath.org/ticket/14912#comment:12>
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.