Waffling (was Re: single-line terinary operators considered harmful)
Stephen Horne
intentionally at blank.co.uk
Wed Mar 5 22:20:32 EST 2003
On Wed, 5 Mar 2003 12:31:34 -0700, Steven Taschuk
<staschuk at telusplanet.net> wrote:
>Quoth Stephen Horne:
> [...]
>> When I was saying that optionalness of the semicolon makes the
>> difference between separation and termination, [...]
>
>So, in Python:
> [1, 2, 3,]
> [1, 2, 3]
>Is the comma a terminator or a separator?
Same thing. With either semicolons for (at least Pascal) statements
and commas in the above lists, the most pragmatic answer is 'who
cares'. Of course I tend to see commas as separators and find your top
example strange, and of course I might well see semicolons the same
way if I hadn't used them as terminators in several other languages.
> while ((*p_Dest++ = *p_Src++) != 0)
> ;
I'm not sure. With modern compilers, using side effects like this is
IMO inherently bad - without the side-effects the loop has no purpose.
So while your right about the 'this line intentionally left blank'
effect, I still wouldn't use it myself. This style of code had value
when C was created (before decent optimisers had been developed), but
IMO it's had its day.
>It's not redundant at all: 0*1 and 0*[] yield objects of different
>types; if x is an instance of a user-defined vector class, the
>multiplication should return the zero vector, not 0; and so forth.
>The second operand must be evaluated to achieve this polymorphism.
Of the mistakes I've made recently, this is certainly the most
annoying. Damn.
--
steve at ninereeds dot fsnet dot co dot uk
More information about the Python-list
mailing list