On Apr 26, 2009, at 6:46 AM, Dag Sverre Seljebotn wrote:

> Dag Sverre Seljebotn wrote:
>> Robert Bradshaw wrote:
>>> I think we're going to want to support the operator= in a limited
>>> sense that one is allowed to do conversions from one type to another
>>> (the declaration could be totally different, and potentially the  
>>> same/
>>> similar as whatever we settle on for "operator T()"). So rather than
>>> the hypothetical
>>
>> a) I don't see where operator= enters the picture here.
>> b) Even if you could do this, this is only hot-fixing one very  
>> specific
>> consequence of a much larger body of problems. I have a feeling you
>> could go around forever fixing specific cases with native Cython  
>> support
>> and get something massively complicated (and impossible to guess)
>> compared to my proposal for embedded C++ macros.
>
> This was rather unfair of me. You said:
>
> """
> I would prefer
>
> class MyCollection:
>        X __getitem__(K idx)
> """
>
> Which is not by any means a hotfix, as it is just mapping over the C++
> declaration!

My point was that the concept of "overloading based on return type"  
is foreign to Python, Cython, C++, and C, so I'd rather not introduce  
it. (It also very easily leads to ambiguities.) What exactly X is  
need not be exposed, just that it can be converted to both an A and a B.

> So I'll rephrase: Until I see it, I remain curious about how one is
> going to select a subset of C++ semantics to support which
>   a) maps to Cython semantics without too many wierd, exceptional  
> rules
> which one has no chance of guessing (which then defeats the purpose of
> pretending to support operatorX-notation in the first place)
>   b) allows wrapping of most C++ libraries without writing a wrapper
> C++-side which is more Cython-subset-friendly.

This is a thorny problem. In terms of operators, I would like to see  
at least:

1) Binary operators
2) A sensible getitem/setitem syntax
3) The ability to declare conversions (e.g. you can assign an int to  
this type, or assign this type to a double).
4) (maybe) an easy way to use the dereferencing * and ++/-- because  
of iterators.

- Robert

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

Reply via email to