Dag Sverre Seljebotn, 03.07.2010 09:40:
> From: Stefan Behnel
 >> toki doki, 02.07.2010 17:57:
>>> I understand correct handling of c++ references will be difficult
>>> to solve
>>
>> Absolutely.
>
> NOTE that this problem is equally present on function arguments: In
> Python,
>
> f(x)
>
> doesn't ever change the value of x! While in C++, f could take a
> reference. I'd like Cython to not follow C++ here.

Same from here.


> There's been long threads about this in the past. My suggestion was to
> treat references as pointers in Cython (they are, after all, C++ syntax
> csandy for pointers)::
>
> f(&x) # output as f(*(&x)) in C++
> vec.at(idx)[0] = 0
>
> I still think this is the lesser of all evils. I suppose a special case
> should be made for operator[] (C++ only has a getitem operator while
> Python distinguish getitem/setitem, so some kind of special rule is
> needed here anyway).

This doesn't exactly make the code beautiful or well readable, but it does 
make the 'feature' usable without breaking any language constraints, and I 
think once you get used to it, it'll be clear enough. We shouldn't forget 
that this can only ever be used on explicitly (or implicitly but obvious) 
typed names anyway, so the information that is required to interpret the 
operation in the code will be somewhat close for the reader.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to