#16532: Weak morphism created with register_coercion can result in invalid 
coercion
----------------------------+------------------------
       Reporter:  tscrim    |        Owner:  tscrim
           Type:  defect    |       Status:  new
       Priority:  critical  |    Milestone:  sage-6.3
      Component:  coercion  |   Resolution:
       Keywords:            |    Merged in:
        Authors:            |    Reviewers:
Report Upstream:  N/A       |  Work issues:
         Branch:            |       Commit:
   Dependencies:            |     Stopgaps:
----------------------------+------------------------

Comment (by SimonKing):

 Replying to [ticket:16532 tscrim]:
 > First noted on #15475. Given `UniqueRepresentation` parents `A, B`  and
 a coercion `phi : A -> B` that was constructed/registered in the
 `__init__` of `A` by using `register_coercion`.

 Is this a typo? Or is it really the case that a coerce map into B is
 registered during ''creation of A'' by calling `register_coercion` ''on
 B''? This would be a misuse.

 > Next suppose that `B` becomes garbage collected, and then so does `phi`.

 That's the expected/preferred behaviour, since otherwise we'd have memory
 leaks.

 > Then `B` is recreated. Expecting there to be a coercion map from `A ->
 B`, the user becomes very surprised when Sage responds with an errors
 saying there is no coercion map.

 That's why the coerce map from A to B should either be registered ''during
 creation of B'' using `register_coercion, or (as Nils pointed out) should
 be registered using `register_embedding` during creation of A, which
 assumes that A embeds into B and may be done only once.

 > Right now I'm too tired to come up with a minimal example, but is this a
 case of misuse

 Misuse.

--
Ticket URL: <http://trac.sagemath.org/ticket/16532#comment:2>
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/d/optout.

Reply via email to