Wednesday, March 25, 2020

Digest for comp.lang.c++@googlegroups.com - 25 updates in 6 topics

Frederick Gotham <cauldwell.thomas@gmail.com>: Mar 25 01:34AM -0700

I'm writing a paper that I want translated into 6 languages before I publish it:
German, Russian, Chinese(Mandarin), Spanish, French, Arabic
 
My paper will include C++ code that is heavily commented, so whoever's translating my paper will need to know how to translate comments like this:
 
if ( p ) *p = 0; /* Careful not to dereference nullptr */
 
memcpy(p,&i,0); /* Don't use '=' in case not aligned */
 
My paper in total will be in the region of about 600-800 words to translate. I'm hoping to purchase a package deal for all 6 languages which won't leave me too much out of pocket.
 
Any recommendations?
Jorgen Grahn <grahn+nntp@snipabacken.se>: Mar 25 11:24AM

On Wed, 2020-03-25, Frederick Gotham wrote:
> translate. I'm hoping to purchase a package deal for all 6 languages
> which won't leave me too much out of pocket.
 
> Any recommendations?
 
Do programmers in these countries expect comments to be in their
native language? For the combination C++ / Sweden, I have never seen
it: code is IME always in English, at work and at university.
(But I admit we are fairly extreme in that area.)
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
cdalten@gmail.com: Mar 25 05:09AM -0700

On Wednesday, March 25, 2020 at 1:34:27 AM UTC-7, Frederick Gotham wrote:
 
> memcpy(p,&i,0); /* Don't use '=' in case not aligned */
 
> My paper in total will be in the region of about 600-800 words to translate. I'm hoping to purchase a package deal for all 6 languages which won't leave me too much out of pocket.
 
> Any recommendations?
 
Well, just a minor point. Spanish in (parts of) Spain is referred to as Castellano whereas Spanish in parts of Latin America is referred to as Spanish. This kind of matters because both Spain and Latin America speak slightly different dialects of Spanish.
Real Troll <Real.Troll@Trolls.com>: Mar 25 08:15AM -0400

On 25/03/2020 08:34, Frederick Gotham wrote:
 
> Any recommendations?
 
First publish the paper in your own language and let the readers decide
whether it is worth wasting time translating it into other languages.
Frederick Gotham <cauldwell.thomas@gmail.com>: Mar 25 02:32AM -0700

On Monday, March 23, 2020 at 12:04:11 PM UTC, Öö Tiib wrote:
 
> if (threads[i].joinable()) threads[i].join();
 
 
I only ever call "join" without checking that it's 'joinable' beforehand (even if I know that the thread entry point function might have returned).
 
Even if you do check that it's joinable first, it might not be joinable a few microseconds later when you try to join it.
 
Can't we just simply call "join"?
"Öö Tiib" <ootiib@hot.ee>: Mar 25 02:50AM -0700

On Wednesday, 25 March 2020 11:32:19 UTC+2, Frederick Gotham wrote:
 
> > if (threads[i].joinable()) threads[i].join();
 
> I only ever call "join" without checking that it's 'joinable' beforehand (even if I know that the thread entry point function might have returned).
 
> Even if you do check that it's joinable first, it might not be joinable a few microseconds later when you try to join it.
 
That sounds like you call join concurrently?
It is AFAIK specified to be data race (results with undefined behavior).
 
 
> Can't we just simply call "join"?
 
AFAIK it will throw std::system_error with code() returning
std::errc::invalid_argument .
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 25 11:17AM +0100

On 25.03.2020 10:32, Frederick Gotham wrote:
 
> Even if you do check that it's joinable first, it might not be
> joinable a few microseconds later when you try to join it.
 
> Can't we just simply call "join"?
 
For the scenario at hand you can, and should.
 
However, a default-constructed `std::thread` is not joinable.
 
 
- Alf
Bonita Montero <Bonita.Montero@gmail.com>: Mar 25 11:23AM +0100

> And that is just:
 
> if (threads[i].joinable()) threads[i].join();
 
 
If you have C++20, better use jthread.
"Öö Tiib" <ootiib@hot.ee>: Mar 25 03:26AM -0700

On Wednesday, 25 March 2020 12:17:46 UTC+2, Alf P. Steinbach wrote:
 
> > Can't we just simply call "join"?
 
> For the scenario at hand you can, and should.
 
> However, a default-constructed `std::thread` is not joinable.
 
The joined thread is also not joinable and ...
 
/* Do stuff */
 
... does not specify if it contains joins or not so my spinal cord
added the check of joinable(), I did not even think of it.
"Öö Tiib" <ootiib@hot.ee>: Mar 25 03:30AM -0700

On Wednesday, 25 March 2020 12:23:25 UTC+2, Bonita Montero wrote:
> > And that is just:
 
> > if (threads[i].joinable()) threads[i].join();
 
> If you have C++20, better use jthread.
 
C++2020 can not be used in real projects. It usually takes 2 years
or more for compilers to fix their defects and for teams to prepare
to migrate.
Frederick Gotham <cauldwell.thomas@gmail.com>: Mar 25 04:16AM -0700

On Wednesday, March 25, 2020 at 10:31:11 AM UTC, Öö Tiib wrote:
 
> C++2020 can not be used in real projects. It usually takes 2 years
> or more for compilers to fix their defects and for teams to prepare
> to migrate.
 
You know those guys who still program in K&R C and refuse to move on to C89?
 
Well 20 years from now I'm gonna be the guy stuck in C++11. They're just adding too much stuff.
David Brown <david.brown@hesbynett.no>: Mar 25 12:22PM +0100

On 25/03/2020 12:16, Frederick Gotham wrote:
>> or more for compilers to fix their defects and for teams to prepare
>> to migrate.
 
> You know those guys who still program in K&R C and refuse to move on to C89?
 
No. They don't exist. (There are programs written in K&R C that are
still maintained, and people may do so without modernising the language.
But that's a different thing.)
 
There are plenty of people who program in C89/C90 and haven't moved on
to C99.
 
 
> Well 20 years from now I'm gonna be the guy stuck in C++11. They're just adding too much stuff.
 
There are plenty of people who stick to C++11. It seems a bit silly to
me, if you have the choice (there can be many reasons why you might not
have a choice). If there are features of C++14 or later that you find
useful, use them - if you don't like a feature, don't use it.
Paavo Helde <myfirstname@osa.pri.ee>: Mar 25 09:37AM +0200

On 24.03.2020 11:00, Ian Collins wrote:
 
> Not on a "standard" US keyboard you don't! I get fed up copy and
> pasting £ when chatting to friends back home!
 
If you have a desktop keyboard with numeric keypad on the right, then in
Windows one should be able to enter £ with Alt-0163. Not sure how
universal this is.
 
Recently I was surprised I still have alt keycodes for öäü in my muscle
memory from 30 years back, and they still worked!
David Brown <david.brown@hesbynett.no>: Mar 25 08:51AM +0100

On 24/03/2020 16:25, James Kuyper wrote:
> that "compose-key ~ a" should produce an a with an umlaut over it. When
> I type "shift right-alt ~" it brings up a selector from which I can
> choose which of the currently open windows to switch to.
 
The compose key is not normally enabled by default on Linux systems
(AFAIK). I remember keyboards from Sun Stations at university having a
dedicated compose key, but there isn't one on normal PC-style keyboards.
 
So you configure it in your keyboard settings for your desktop, with a
wide choice of keys. I always make it the "Scroll Lock" key, since that
is perhaps the most unused I have.
David Brown <david.brown@hesbynett.no>: Mar 25 09:08AM +0100

On 24/03/2020 21:41, Keith Thompson wrote:
 
> I have an "Alt Gr" key on my keyboard (Windows laptop), but it doesn't
> appear to do anything useful. There might be a way to make it work, but
> I'm not sufficiently motivated at the moment to look into it.
 
I think, but am not sure, that it is usually considered the same as Alt
on keyboard layouts which don't have a third symbol on keys. (For
example, my "7" key has "/" with shift and "{" with alt-gr, all marked
on the keyboard.)
 
On Linux systems you have multiple choices of layouts as well as the
default. So for US keyboards, as well as the standard "English (US)" I
see "US, alternative international", "US, international with dead keys",
"US, with euro on 5". I'm guessing that for some of these, alt-gr would
give access to more symbols. Then there are a range of other options
you can set if you want.
 
It is, as you say, a matter of motivation. If you need extra letters or
symbols on a regular basis, the support is there. Clearly, people who
regularly use a significantly different language will generally use
alternative keyboard layouts. But I find that there are a few symbols
and letters that turn up in my common usage, in addition to the obvious
need for Norwegian letters when I write in Norwegian. I like to be able
to write "100 µF capacitor", "I²C bus", and spell naïve properly.
 
 
> The problem, I think, is either that there's no standard for entering
> characters that don't appear directly on the keyboard, or there are far
> too many standards.
 
The compose key is perhaps the nearest that exists to a standard, having
existed for at least 30 years, but it is not enabled by default on Linux
systems (IME) and is not supported at all on Windows. So no, not much
of a standard!
 
>> I thought even US keyboards had § and ¤. I guess you are more limited
>> than I thought.
 
> I suggest doing an image search for US keyboard layouts.
 
No need, now! (I should perhaps have done so earlier.)
Bonita Montero <Bonita.Montero@gmail.com>: Mar 18 06:27PM +0100

>> v can be a type castable to an integer.
 
> Or a suitable operator== overload. Please learn a little bit of C++.
 
If you arguing against yourself there's nothing more to say.
 
> In most other instances almost everyone can figure this out too.
> Just not you.
 
I do it like everyone, but this is an unecessary effort.
Ian Collins <ian-news@hotmail.com>: Mar 19 09:05AM +1300

On 19/03/2020 07:41, Sam wrote:
 
>>> Or a suitable operator== overload. Please learn a little bit of C++.
 
>> If you arguing against yourself there's nothing more to say.
 
> Here are your toys. You can go home now.
 
See what happens when you feed the troll?
 
--
Ian.
Bonita Montero <Bonita.Montero@gmail.com>: Mar 19 06:41AM +0100

> Not only that, but it is not necessary to also use std::vector,
> std::list, or any other container in the C++ library. ...
 
It doesn't depend on the type of container.
It's usually not possible to guess the contained type.
Bonita Montero <Bonita.Montero@gmail.com>: Mar 17 06:37AM +0100

> I suppose that it's a matter of personal preference.
 
If I have to figure out of which type a container is I doing an
auto in a for, that's not a matter of preference. If I f.e. have
a pair<const key, value>, I know immediately that I'm using a map
or unordered_map.
Bonita Montero <Bonita.Montero@gmail.com>: Mar 17 06:37PM +0100

> will work for that map. But replacing that container with a std::vector
> of tuples will also work, if it becomes necessary. You'll be surprised
> to learn that the above line of code will remain unchanged.
 
This ease doesn't justify the lesser readability.
Bonita Montero <Bonita.Montero@gmail.com>: Mar 18 05:59PM +0100

>> There's no limitation on my side.
 
> ... That's a major limitation of one's ability to understand C++ code.
 
Everyone without your crystal ball has this limitation.
 
>      ++number_of_zeroes;
>   }
> }
 
v can be a type castable to an integer.
 
> Noone really needs to know the type of the container, in this instance.
 
But in most other instances.
Bonita Montero <Bonita.Montero@gmail.com>: Mar 19 12:59PM +0100

Am 19.03.2020 um 12:46 schrieb Frederick Gotham:
> *reinterpret_cast<array<char,4> *>(&abc[8])
> );
> }
 
Why should someone do this ?
You could stick with pointers, iterators or a span.
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Mar 18 03:11PM -0700

On 3/18/2020 3:10 PM, Chris M. Thomasson wrote:
 
>>> you need to provide snippets of your code
 
>> I'm still drawing pictures. I'll have code in a day or two.
 
> Make sure to give the folks over on sci.crypt a chance to take a look.
 
Fwiw, I am at a point where they are telling me that my cipher is beyond
their expertise.
Real Troll <Real.Troll@Trolls.com>: Mar 18 04:50PM -0400

On 18/03/2020 17:59, Frederick Gotham wrote:
> <tl;dr>
 
> Does anyone have any thoughts on this?
 
Assuming you are not a troll, to get any advice or views from
experienced C++ programmers (Kuyper, Montero or Helde to name just a
few) , you need to provide snippets of your code. There is no point in
asking anything if you are not able to show us what exactly you have
done so far.
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Mar 18 03:10PM -0700

On 3/18/2020 3:09 PM, Frederick Gotham wrote:
> Real Troll wrote:
 
>> you need to provide snippets of your code
 
> I'm still drawing pictures. I'll have code in a day or two.
 
Make sure to give the folks over on sci.crypt a chance to take a look.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: