On Tue, Mar 27, 2018 at 9:37 PM, Eric Gourgoulhon
<egourgoul...@gmail.com> wrote:
> Hi Simon, hi Erik,
>
>
> Le mardi 27 mars 2018 21:09:08 UTC+2, Simon King a écrit :
>>
>> Hi Erik,
>>
>> On 2018-03-27, Erik Bray <erik....@gmail.com> wrote:
>> > 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.
>>
>> I don't think it'd be a good idea. Reason: What should be the default
>> value of "as_element_of"? Should it be the parent of "a"? But then, you
>> immediately have the same problem as we have now, which is the
>> surprising (to some) fact that (3/1).is_prime() returns False. And the
>> work-around
>>   (3/1).is_prime(as_element_of=ZZ)
>> would be more verbous than
>>   ZZ(3/1).is_prime()
>>
>> Best regards,
>> Simon
>>
>
>
> Why not introducing a different function, is_prime_integer() say, keeping
> is_prime() as it is now?
> Of course, x.is_prime_integer(), or is_prime_integer(x), would return
> ZZ(x).is_prime().
> Then, for the casual user, we should advertise (in examples, tutorials,
> etc.) the use of is_prime_integer() over is_prime().
> Note that the casual user may discover is_prime_integer() by the standard
> TAB mechanism, since its name starts by "is_prime". Facing the choice
> between the two functions, he would probably (hopefully?)  opt for
> is_prime_integer(), which is self-explanatory.

+1 to Eric's idea.  I think that should resolve the issue reasonably
well, since for the "casual" user we're talking about it's integers
they're probably concerned with--it doesn't need to become a slipper
slope or anything.

As a bonus, the curious undergrad will be surprised that there are
separate is_prime and is_prime_integer and maybe learn something new.

-- 
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