POV-Ray : Newsgroups : povray.off-topic : Standard libraries : Re: Standard libraries Server Time
6 Sep 2024 17:18:45 EDT (-0400)
  Re: Standard libraries  
From: Darren New
Date: 7 Mar 2009 16:49:23
Message: <49b2ebe3$1@news.povray.org>
Warp wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> Warp wrote:
>>> Darren New <dne### [at] sanrrcom> wrote:
>>>> Warp wrote:
>>>>>     std::for_each(someList, [&total](int x) { total += x });
>>>> And, really, what's the advantage of this over a normal for loop?
>>>   Nothing. Since it's C++ code, it sucks.
> 
>> You know, if you're not mature enough to have a civil conversation, you 
>> don't really need to participate.
> 
>   You really are a master of trolling, you know. I have to admire that.
> 
>   First you succeed in trolling me with your unusually heavy and biased
> C++ bashing, and then you try to make it look like all you wanted to do
> is have a simple civil conversation.

Seriously, in this post, the question was, *really*, what's the advantage?

Really. That's all I meant. That's why I said "really".  I'm not trolling. 
I'm trying to get someone who *does* understand the feature to tell me the 
advantage.

I understand the advantage of lambda expressions. I don't understand the 
advantage of what C++ calls lambda expressions over just using regular 
inline code, since the lambda expression isn't really a self-contained value 
you can return from its scope.

> Every question you made about new C++
> features were aimed solely at trying to find flaws in them. When your
> questions were answered, you asked more questions, trying to find flaws.

I'd say "limitations" rather than flaws. I tend to understand what a feature 
is intended for, and find that limitations on the feature are where I get 
tripped up.

> You continued asking questions until you found some flaw you could point
> out. (Eg. first you asked if lambda functions would use such a cumbersome
> syntax as boost::lambda, and when you got shown that they won't, you asked
> if you can assign lamdbda functions to variables, and when you got shown
> that you can, you continued asking and asking until you found something
> that you can consider a flaw so that you could mock the whole feature.

Nope. I knew C++ can't support lambdas in the usual sense of the word (as a 
mechanism for constructing closures). I was trying to figure out at what 
point it breaks down. The pointer to the part of the wikipedia page 
explaining it's undefined behavior to refer to a variable in a scope that 
has exited removed my confusion.

>   You really are good at trolling. Personally I could not get even near
> that level of mastery.

While I appreciate the complement, I really wasn't trying to piss you off. 
Maybe due to the social circles I've hung out in over the last few years, I 
tend to do such things more often than I should, unintentionally. I'm sorry 
if I've gotten your blood pressure up, and I hope I haven't disturbed your 
weekend.

I'll try to phrase things differently in the future, but even when I 
specifically disclaim I'm saying anything about you, you sometimes take 
things personally, so I'm not sure how much more I can make the questions 
sound as I mean them to be taken.

>   Another example: You could give std::sort() a comparator as a lambda
> function which has access to the variables in the local scope, something
> which is very laborious to do currently.

Hmmm. OK, thanks. I can see where something like that could be convenient. 
Most places I've seen that need that sort of thing pass in a "client data" 
sort of opaque pointer to allow it, so I guess this new stuff could obviate 
the need to design that in at the application layer.

-- 
   Darren New, San Diego CA, USA (PST)
   My fortune cookie said, "You will soon be
   unable to read this, even at arm's length."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.