[Pyrex] [Fwd: Re: The "++" operator gets stripped out (as in "++x")]

Lenard Lindstrom len-l at telus.net
Fri Jan 18 03:19:43 CET 2008



-------- Original Message --------
Subject: 	Re: [Pyrex] The "++" operator gets stripped out (as in "++x")
Date: 	Thu, 17 Jan 2008 00:20:38 -0800
From: 	Robert Bradshaw <robertwb at math.washington.edu>
To: 	cython-dev at lists.berlios.de
CC: 	Lenard Lindstrom <len-l at telus.net>
References: 	<47812024.6060804 at pnylab.com> 
<478129D3.5000402 at lexicon.net> <47812AB9.8060001 at pnylab.com> 
<4781352B.4090707 at telus.net> 
<94A775E3-539E-4D39-9AF5-D5DD4803C38A at math.washington.edu>



This now produces a warning.

On Jan 7, 2008, at 4:10 PM, Robert Bradshaw wrote:

>
> On Jan 6, 2008, at 12:08 PM, Lenard Lindstrom wrote:
>
>> This is not as simple as it appears. Pyrex is bases on Python, not
>> C. So
>> its grammar should be consistent with Python. In Python, the unary  
>> '+'
>> can be overridden. So if x where a Python variable then ++x is
>> equivalent to +(+x). Now the unary '+' can also be overloaded in C+
>> +. So
>> for future considerations in C++ support shouldn't ++x also
>> translate to
>> +(+x) for statically cdef'd variables to be consistent with Python
>> grammar.
>
> Maybe for the future, but for now I certainly think there should be a
> warning.
>
> - Robert
>
>
>>
>>
>> Lenard Lindstrom
>>
>>
>> Dan Gindikin wrote:
>>> This thought occurred to me, but perhaps there ought to at least
>>> be a warning in
>>> this case? It's an easy mistake to make.
>>>
>>> John Machin wrote:
>>>
>>>> Dan Gindikin wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> It appears the "++" prefix operator gets silently stripped out.
>>>>> If you
>>>>> have the following,
>>>>>
>>>>>     cdef int x
>>>>>     x=0
>>>>>     ++x           # in the .c file, this is just "__pyx_v_x"
>>>>>     print x
>>>>>
>>>>> a "0" is printed.
>>>>>
>>>>> This is with version 0.9.6.4
>>>>>
>>>>>
>>>>>
>>>> There is no such thing as a "++" prefix operator in Python and  
>>>> Pyrex
>>>> (and Pyrex doesn't support x += 1). You have two "+" prefix
>>>> operators,
>>>> with the expected result.
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>> _______________________________________________
>> Pyrex mailing list
>> Pyrex at lists.copyleft.no
>> http://lists.copyleft.no/mailman/listinfo/pyrex
>
>
> _______________________________________________
> Pyrex mailing list
> Pyrex at lists.copyleft.no
> http://lists.copyleft.no/mailman/listinfo/pyrex





More information about the Pyrex mailing list