|
![](/i/fill.gif) |
Warp wrote:
> It's not like the new features would *replace* existing features. They
> are pure additions. So I really don't see your point.
> Lambdas will be at core language level in the exact same way as eg.
> generics in Java are at cure language level. I don't see your problem.
They interact poorly with the rest of the language, putting arbitrary
limitations on them, and thus not actually solving the problems lambdas are
usually used to solve. Thereby generally forcing yet another round of syntax
and kludge piled on top of the existing language, in the next release when
people try to fix *that*.
> And lambdas in the new C++ are syntactic sugar. The compiler will generate
> exactly the same machine code as if you had written a non-lambda function.
Yeah. Which means they aren't lambdas. They're just called lambdas.
>> Sure. And it has new syntax for new stuff, and it's cleanly integrated with
>> the rest of the language.
>
> You say it like the new C++ features aren't. Care to explain?
I thought the lambdas C++ was adding were actually lambdas. Since it's
impossible to actually implement lambda expressions in C++, I thought it
would be difficult to implement lambdas cleanly. I was right, but what C++
calls lambdas are actually implemented cleanly and integrated well. They
just aren't lambdas. They're anonymous functions.
>> I'm not. I'm criticizing the way C++ adds new features, not that it does.
>
> Right. When other languages add new features (let's say, for example,
> Java adding support for generics), that's ok. But when C++ adds new features,
> that's something to be critiqued.
Criticized, not critiqued.
The difference is that C++ seems to want to have both low-level stuff (like
manual memory management, say, and a lack of run-time type information) and
high-level stuff (like functional programming and sophisticated separate
compilation), and those sorts of things just don't go together well. You
can't have closures in a language without runtime type information.
>> Every new feature in C++ seems to be hurt by (1) not wanting to pay any
>> price if you don't use it,
>
> Care to explain how, for example, lambda functions would add some overhead
> to the C++ language even when you don't use them?
I would, *if* C++ actually was implementing lambda expressions. They're not.
They're implementing inline anonymous functions that don't close over the
free variables.
And yes, exactly, the *reason* that C++'s lambda expressions suck is
*because* the designers of C++ don't want to add any overhead to support it.
>> (2) not wanting to add any syntax for it,
>
> Have you even looked at how lambda functions will be written in the new
> C++ standard? How is it not adding new syntax for it?
A complete lack of any sort of keyword, like, oh, "lambda" maybe?
OK, so I thought they were standardizing the way Boost did it. They aren't.
It's better than that. But still wrong. :-)
>> and (3)
>> interacting poorly and confusingly with every other feature of the language.
>
> Care to elaborate?
A lambda that closes over local variables is undefined if you return it from
the function it was declared in? And (I'd guess) undefined if you use it
outside the block it was declared in if that block declares local variables
that are free inside the lambda expression?
A lambda that closes over a local variable "by value" closes over a
different local variable than another lambda that closes over the same local
variable?
>> If C++ added lambdas and they actually had things like pointers to stack
>> frames and so on, I'd probably not be bothered. But I strongly suspect the
>> lambdas they add are going to have so much brokenness to deal with the lack
>> of automatic memory management and such that it's going to be harder to use
>> lambdas than to just declare your own functions. And I'm betting the syntax
>> will be so baroque it's going to be almost impossible to read without doing
>> parsing in your head, too. Looking the little I did at the Boost lambda's,
>> they're utterly awful compared to any other language with real lambdas built in.
>
> Good thing you are not prejudiced nor biased in the least.
"Prejudiced" would imply that I'm not making judgements based on experience,
but rather based on lack of knowledge. Since I've been using languages that
support lambdas correctly for, oh, decades, as well as languages that can't
and don't try, I think I've called this one properly.
I'm biased against ugly languages that are a pile of hacks to fix flaws in
other hacks.
>>> I don't know if I'm just being paranoid, but I honestly think that you
>>> are doing this for the simple reason that you know that you are going to
>>> troll me.
>
>> No. I just don't like C++.
>
> And for that reason you have to constantly write prejudiced BS about it.
It's neither prejudiced nor BS. What makes you think it's prejudiced?
>> I think the way things get added to C++ is a bad
>> thing for a language.
>
> What way? Care to explain?
Sure. Adding a lambda expression whose evaluation is undefined depending on
where you invoke it and what variables it uses is "bad". The "way" in which
it gets added is "this works in a few limited cases to solve a handful of
specific problems, and if we can't support it well, we'll just do undefined
behavior instead of telling you it's broken."
> And which way would you think would be better?
Either accept that your language isn't suitable for that sort of
programming, or do it right.
>> Python added a lot of really ugly stuff under the covers, too. But it's
>> under the covers, and doesn't get in your way if you don't use it, and it's
>> usable for more than just the one idea the person thought of who suggested
>> it.
>
> First you critique C++ because the ideology is that new features don't
> have any effect if you don't use it.
No. I criticize C++ because the ideology is that new features aren't allowed
to add any overhead if you don't use them, and hence the new features are
broken by design to meet that other goal.
> Now you are praising Python for the exact same thing,
No. I'm simply saying that Python, while under the covers is ugly in some
ways, nevertheless is done *right* in the sense that instead of saying "this
is ugly, and hence broken," they say "this is ugly, but it works right."
> IMO you are just prejudiced and don't know what you are talking about.
When C++ stops adding features that have undefined behavior when you use
those same features the way the rest of the world does, I'll believe that
C++ is adding elegant features. As it is, I'll just have to laugh at people
who say that C++ is adding lambda expressions in the next release, just like
I laugh when people say things like "C++ has automatic memory management as
long as you write all the management code into your application and take
care not to hit the corner cases that blow up your memory model."
--
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
|
![](/i/fill.gif) |