On Tue, Mar 27, 2018 at 11:21 AM, Marc Mezzarobba <m...@mezzarobba.net> wrote:
> John Cremona wrote:
>> However pedantic you are it is very hard indeed to justify this for a
>> package which is intended for a wide class of users:
>>
>> sage: a = 300/100
>> sage: a
>> 3
>> sage: a in ZZ
>> True
>> sage: a.is_prime()
>> False
>
> Yes, but having a.is_prime() return True may break generic code written
> for arbitrary commutative rings that needs to specialize gracefully to
> fields. This looks less likely with Vincent's examples, though factor()
> may be a borderline case.

What about adding an optional argument to the is_prime()
method--something like a.is_prime(as_element_of=ZZ).  It's kind of a
wordy (though I'm sure there's a more succinct spelling) way to write
ZZ(a).is_prime() but at least it's still precise about what you're
asking.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to