On May 13, 2009, at 9:43 PM, Dag Sverre Seljebotn wrote:

> Dag Sverre wrote:
>> What one could do is:
>>
>> short temp_short
>> int temp_int
>> long long temp_longlong
>> switch (sizeof(footype)) {
>>   case sizeof(short): temp_short = ....
>>   case sizeof(int): temp_short = ....
>>   case sizeof(long long): temp_short = ....
>> }
>> ....
>> result... = ((sizeof(footype) == sizeof(short) ? temp_short : ...)
>
> Consider that proof that it is still 06 in the morning here...
>
> The idea holds, but what one must do is make comparisons between types
> (sizeof(footype) > sizeof(bartype)?) to select between two alternative
> temps.
>
> The problem is then when that is used in another expression with a  
> third
> external typedef, which would lead to three possibilities for the  
> temp,
> and so on (in practice I can't see the number of external typedefs  
> used in
> any expression to go above four or five so it's not horrible).
>
> Again, I don't like it, but it shows that there is a way.

Well, considering how infrequently Cython uses temp variables, it  
won't make the code much more verbose, will it? :D

> But I should probably use my Cython time for more worthy goals and  
> just
> tell people that "if you don't know the size of an external typedef,
> declare it at the widest possible type it can be" for now. People  
> can't
> then use overflowing behaviour for external typedefs, which seem OK.


I completely agree. Conversion to/from Cython can be done smarter  
using sizeof(), but for the cases discussed here if one really cares  
about overflow semantics than one has to be careful about defining  
types more precisely, or not mixing external types with builtin int  
types.

You up for testing complex support sometime really soon?

- Robert

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

Reply via email to