Sujet : Re: Why Python When There Is Perl?
De : OFeem1987 (at) *nospam* teleworm.us (Chris Ahlstrom)
Groupes : comp.os.linux.advocacyDate : 28. Mar 2024, 13:50:27
Autres entêtes
Organisation : None
Message-ID : <uu3li3$3htbr$2@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
User-Agent : slrn/1.0.3 (Linux)
rbowman wrote this copyrighted missive and expects royalties:
On Wed, 27 Mar 2024 12:40:32 -0400, Chris Ahlstrom wrote:
>
As an aside, C++20 introduces the "spaceship" operator,
operator <=>. It does a three way comparison, a bit like strcmp():
>
Our programming group moved recently and in bringing the books to the new
location I found a copy of 'Effective C++' 2nd edition that I must have
bought back when since it has my name on the fly leaf. Is that still
useful or have there been too many changes? I see his last book if
'Effective Modern C++' but even that one is for C++14.
>
Moving the books nobody has looked at in years was depressing. Most should
have been moved to the dumpster. 'Programming Perl' may still be valid.
>
I hope C++ doesn't use => for lambdas like C#; that would really be error
prone.
Nah, it's probably more powerful; read the C++14 book from Meyers.
Example below. Note the capture of the function parameters.
/**
* Sets the beats per measure and measures for all existing patterns.
*/
bool
performer::set_beats_per_measure (int bpm, bool user_change)
{
bool result = bpm != m_beats_per_bar;
if (result)
{
set_mapper().exec_set_function
(
[bpm, user_change] (seq::pointer sp, seq::number /*sn*/)
{
bool result = bool(sp);
if (result)
{
sp->set_beats_per_bar(bpm, user_change);
sp->set_measures(sp->get_measures(), user_change);
}
return result;
}
);
}
return result;
}
Here's another one that captures "this"; the module involved puts a bunch
of control functions in a map keyed by MIDI control events. In the early days
of this app it was a shitload of if-statements.
[this]
(
automation::action a, int d0, int d1,
int index, bool inverse
)
{
return loop_control(a, d0, d1, index, inverse);
}
-- Q: Why don't Scotsmen ever have coffee the way they like it?A: Well, they like it with two lumps of sugar. If they drink it at home, they only take one, and if they drink it while visiting, they always take three.