#15303: Coercion discovery fails to be transitive
----------------------------+-------------------------
       Reporter:  nbruin    |        Owner:
           Type:  defect    |       Status:  new
       Priority:  major     |    Milestone:  sage-5.13
      Component:  coercion  |   Resolution:
       Keywords:            |    Merged in:
        Authors:            |    Reviewers:
Report Upstream:  N/A       |  Work issues:
         Branch:            |       Commit:
   Dependencies:  #14711    |     Stopgaps:
----------------------------+-------------------------

Comment (by SimonKing):

 Replying to [comment:3 nbruin]:
 > > For example `B._coerce_embeddings_from[A] = phi`, ''in addition'' to
 `A._coerce_embedding = phi`. Since it is a `MonoDict` and thus has weak
 references to the keys, B would not prevent A from being garbage collected
 (but of course A would still keep B alive, because we registered the
 coerce embedding).
 >
 > Yes, something along those lines. In fact, since
 `_coerce_embeddings_from` and `_coerce_from_list` would serve the same
 purpose from the perspective of coercion discoveries, I think the entries
 in `_coerce_from_list` should also be added to `_coerce_embeddings_from`,
 because it would simplify the code. By then it would make more sense to
 call the attribute `_coerce_from_to_be_used_in_backtracking` and the list
 that is now `_coerce_from_hash` could be `_coerce_from_cached_results`.

 Or shorter: `_coerce_from_backtracking` and `_coerce_from_cache`.

 > By then we should probably be storing ALL maps there in weakened form.

 Probably.

 > The only function of `_coerce_from_list` now is to keep domains alive,
 so it would be more economical to replace that by a list
 `_domains_to_keep_alive` where we can store strong references to the
 domains of the corresponding weakened maps that are now in
 `_coerce_from_to_be_used_in_backtracking`

 I have introduced `Parent._registered_domains` for exactly this purpose,
 at #14711. So, we should extend its use.


 >  - `P._codomains_to_keep_alive`: List of codomains that should be kept
 alive as long as P lives. Normally, such codomains Q would have an entry
 in `Q._coercion_maps[P]`. Just storing a map in P._coerce_embedding would
 also have this effect.

 Yes, and that's why I don't think we need `P._codomains_to_keep_alive`
 (I'd prefer the name `P._registered_codomains`). Even in weakened maps, we
 have a strong reference to the codomain.

--
Ticket URL: <http://trac.sagemath.org/ticket/15303#comment:8>
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.

Reply via email to