Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69256 > unrolled thread

Re: Python language hack for C-style programmers [DO NOT USE!] :-)

Started byPeter Otten <__peter__@web.de>
First post2014-03-28 09:26 +0100
Last post2014-03-28 09:26 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python language hack for C-style programmers [DO NOT USE!] :-) Peter Otten <__peter__@web.de> - 2014-03-28 09:26 +0100

#69256 — Re: Python language hack for C-style programmers [DO NOT USE!] :-)

FromPeter Otten <__peter__@web.de>
Date2014-03-28 09:26 +0100
SubjectRe: Python language hack for C-style programmers [DO NOT USE!] :-)
Message-ID<mailman.8660.1395995177.18130.python-list@python.org>
Chris Angelico wrote:

> On Fri, Mar 28, 2014 at 6:46 PM, Peter Otten <__peter__@web.de> wrote:
>> Why would you guess if you can check? Just fire up the interactive
>> interpreter^W^W compiler:
> 
> Partly because there's a difference between valid C++ and valid input
> to the G++ compiler :) Knowing that it works with g++ doesn't tell me
> that it's actually valid, and I don't feel like digging into the specs
> to find out where you're guaranteed to be allowed to do that. (I could
> probably test it with one of the language spec options, but then it
> still depends on the exact version of GCC and the exact spec chosen.)

I don't have the spec handy, only an old copy of "The C++ Programming 
Language" which has

"""
To avoid accidental misuse of a variable, it is usually a good idea to 
introduce the variable into the smallest scope possible [and] to delay the 
definition of a local variable until one can give it an initial value.
[...] One of the most elegant applications of these two principles is to 
declare a variable in a condition. Consider:

if (double d = prim(true)) {
    left /= d;
    break;
}
"""

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web