On Mar 20, 2009, at 4:40 PM, Lisandro Dalcin wrote:

> Are you saying with all this that
>
> cdef object CHAR_MAX = <char>((<unsigned char>-1)>>1)
>
> will not give me in CHAR_MAX a (Python) integer with the maximum value
> representable in a C char?

Under my understanding, this will behave as it always did.

>>>> BTW, I'm not sure how type casts should be handled. What about  
>>>> something
>>>> like this:
>>>>
>>>>     cdef int x = 3 + <long><char>(2**10)
>>>>
>>> This is asking for a wraparound if you ask me. I'd say 2**10  
>>> folds, then
>>> leave it to runtime, because we cannot know the type sizes (at  
>>> least of
>>> long).
>>>> ? Whereas
>>>>
>>>>     cdef int x = 3 + <int>(2**10)
>>>>
>>>> would simplify just fine...
>>>>
>>> However,
>>> cdef long x = 3 + <long>(2**34)
>>>
>>> would simplify fine on non-Windows 64-bit but not otherwise. I'd be
>>> reluctant to simplify casts at all because the only intention I  
>>> can find
>>> in code like that is to do a "& MAX_VALUE_OF_TYPE", and that  
>>> stuff is
>>> much better left to the compiler.
>>
>> Yep. I also think that it's rather unlikely that users will put a  
>> type
>> cast before constants in places where compile time values are  
>> actually
>> interesting (such as loop ranges/steps).

Yes, we shouldn't fold casts.

- Robert


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

Reply via email to