#17119: Disallow pari(None)
-------------------------------------+-------------------------------------
       Reporter:  jdemeyer           |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.4
      Component:  interfaces         |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Jeroen Demeyer     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/jdemeyer/ticket/17119            |  4476266587733622582d32b1b7015c56ae97bf69
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by pbruin):

 PARI has its own equivalent of `None`, namely `gnil`.  This is internally
 a `t_INT` with value 0, but is treated specially by virtue of its memory
 address.  It is returned by things like evaluating the empty string,
 constructions like `if(0,1)`, etc.  In Sage we currently convert `gnil` to
 None:
 {{{
 sage: pari('') is None
 True
 sage: pari('if(0,1)') is None
 True
 }}}
 I think we should decide on a uniform behaviour for the relationship
 between `gnil` and `None`.  It seems that we have the following options:
 - Always convert `gnil` to Python `None`, and make `pari(None)` return
 `None`.
 - Allow wrapping `gnil` (and possibly other PARI objects that are not on
 the stack) in a Sage `gen` without copying it, so PARI recognises it as
 `gnil`.  In particular, `pari(None)` (like `pari('')`), will be such a
 `gen` wrapping `gnil`.  This probably prints as 0 by default, but this
 could be changed by the `__repr__()` method.
 - Stop treating `gnil` specially, identifying it with `gen_0`.  Make this
 consistent by defining `pari(None) = pari(0)`.  This is what GP does when
 assigning to a variable:
 {{{
 gp > if(0,1)         \\ returns gnil
 gp > x = if(0,1); x  \\ the result of gcopy(gnil) is identical to gen_0
 %2 = 0
 }}}

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