On Fri, Mar 28, 2014 at 7:26 PM, Peter Otten <__pete...@web.de> wrote:
> 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;
> }
Okay! Then I withdraw the "or, to my knowled
Chris Angelico wrote:
> On Fri, Mar 28, 2014 at 6:46 PM, Peter Otten <__pete...@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 :) Know
On Fri, Mar 28, 2014 at 6:46 PM, Peter Otten <__pete...@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'
Chris Angelico wrote:
> On Fri, Mar 28, 2014 at 12:44 PM, Dave Angel wrote:
>>> if (array m = Regexp.split2(some_pattern, some_string))
>>> do_something(m);
>>>
>>
>> I don't know for certain about if, but you can declare (in C++) a
>> new variable in for, which is a superset of if. Scope en
On Fri, Mar 28, 2014 at 12:44 PM, Dave Angel wrote:
>> if (array m = Regexp.split2(some_pattern, some_string))
>> do_something(m);
>>
>
> I don't know for certain about if, but you can declare (in C++) a
> new variable in for, which is a superset of if. Scope ends when
> the for does.
Yeah,
Chris Angelico Wrote in message:
> On Fri, Mar 28, 2014 at 3:08 AM, Tim Chase
> wrote:
>> Multiple times, I've seen someone want something like what C-style
>> languages offer where assignment is done in a test, something like
>>
>> if (m = re.match(some_string)):
>> do_something(m)
>
> I
On Fri, Mar 28, 2014 at 3:08 AM, Tim Chase
wrote:
> Multiple times, I've seen someone want something like what C-style
> languages offer where assignment is done in a test, something like
>
> if (m = re.match(some_string)):
> do_something(m)
If you want a language where you can do this sort
On Fri, Mar 28, 2014 at 3:08 AM, Tim Chase
wrote:
> So when I stumbled upon this horrific atrocity of language abuse and
> scope leakage, I thought I'd share it.
>
> if [m for m in [regex.match(some_string)] if m]:
> do_something(m)
>
> And presto, assignment in an if-statement.
And presto,
Multiple times, I've seen someone want something like what C-style
languages offer where assignment is done in a test, something like
if (m = re.match(some_string)):
do_something(m)
So when I stumbled upon this horrific atrocity of language abuse and
scope leakage, I thought I'd share it.