On Thu, May 29, 2014 at 2:41 AM, Simon King <simon.k...@uni-jena.de> wrote:
> Hi William,
>
> On 2014-05-28, William Stein <wst...@gmail.com> wrote:
>> With properties, guess what happens?   Suppose f.something is a
>> property that's an immutable number, e.g., the determinant of a
>> matrix.
>>
>>  sage: a = matrix(...)
>>  sage: a.det?
>>  docstring about integer!
>
> That's not true, if det is a property:
>  sage: class MyMatrix(object):
>  ....:     @property
>  ....:     def det(self):
>  ....:         "Determinants are computed by..."
>  ....:         return 5
>  ....:
>  sage: m = MyMatrix()
>  sage: m.det
>  5
>  sage: m.det?
>  Type:       property
>  String Form:<property object at 0x904b2fc>
>  Docstring:  Determinants are computed by...
>
>> And the above just makes absolutely no sense.  The user expects to get
>> a docstring about a function that computes the determinant, ...
>
> She in fact does. That's the difference between attributes and
> properties.

Simon -- for the record, that the above works now is some clever and
*relatively new* trickery in IPython.
For example, in SageMathCloud (and sagenb and straight Python), which
don't use IPython for introspection, m.det? or

   sage: help(m.det)

work exactly like I said -- they return help on Integer.
Obviously, the IPython devs got fed up with this and implemented some
trick to get around this for ?, which we're automatically inheriting
in command-line Sage (and which I should figure out and implement for
notebooks...).   I can't see any possible way to patch help to deal
with this though, since it's just a function that gets the integer 5
as input.  It doesn't know where 5 came from.

Thanks for the clarification, but note that this wan't my only
argument against properties for interactive Sage use, and it's
definitely one that can be worked around in some cases.

>
> However:
>
>> Another issue is that frequently in math we have algorithms/options to
>> functions, e.g.,
>>
>>   sage: a.det(algorithm="padic")
>>
>> Expressing the above with properties is awkward and hard to discover.
>
> +1
>
> Best regards,
> Simon
>
>
> --
> 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 http://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.



-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
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 http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to