On Feb 26, 2009, at 1:45 AM, Nicolas M. Thiery wrote:

>       Hi Sébastien!
>
>>    Couldn't we define something like :
>>
>>    def _len_(self):
>>        return ...
>>
>>    that behave like we want as it is done for _str_ and _repr_ ?
>
> That could be an option. But:
>
>  - It can be confusing for the user to have two functions with almost
>    the same name (__len__ / _len_) and subtle semantic difference.
>    (for the record, I also find _str_/__str__ confusing).

I agree--we mostly use this convention when some automated  
preprocessing/wrapping needs to be done, e.g. coercion. I think  
cardinality is the best name.

>  - We really want the function to appear in the automatic completion.
>    (or alternatively that could be called via a standard function like
>    len(...) had we been lucky enough to be able to use len).
>
>  - len conveys more a computer science meaning rather than a
>    mathematical meaning.

I could see __len__ calling cardinality, but raising an overflow  
error on infinite (or > maxint) results.

BTW, NonNegative- and PostiveIntegers were implemented by David Roe  
as part of the Coercion branch, but never ended up getting merged  
over (partially due to lack of doctests).

- Robert


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to