Robert Bradshaw, 03.11.2010 02:16:
> On 2 November 2010 20:02, Stefan Behnel wrote:
>> Robert Bradshaw, 02.11.2010 07:17:
>>> On Sun, Oct 31, 2010 at 8:44 PM, Brett Calcott wrote:
>>>> cdef class PythonVector2d:
>>>> cdef Vector obj
>>>> properties:
>>>> public obj.x as x
>>>> public obj.y as y
> <--- snip -->
>> For this case, I'd prefer a version entirely without body, maybe even
>>
>> property x = obj.x
>>
>> although the "as" version would also work. However, it's not so clear from
>> the above that both setter and getter get generated, and how you would get
>> only the getter for read-only access, for example. And why not have a
>> "delattr" as well? May make sense in some cases.
>
> setters, getters, (and delattrs?) would be defined iff they make sense
> on the expression in question. One could imagine
>
> property readonly obj.x as x
>
> or something like that.
I'm generally ok with such an addition.
What about something like
cdef class PythonVector2d:
cdef Vector obj
cdef public x from obj.x
? I'm wondering if it isn't better to keep the existing attribute syntax
than to introduce a new property syntax. Although, a counter argument could
be that it isn't really an attribute...
Next try:
cdef class PythonVector2d:
cdef Vector obj:
property x
property readonly y as my_y
Makes it clearer where the properties actually come from.
Anyway, I won't object to your plain "property ... as ..." proposal above.
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev