Tuesday, March 28, 2023

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

Paavo Helde <eesnimi@osa.pri.ee>: Mar 28 03:40PM +0300

27.03.2023 23:11 Pawel Por kirjutas:
 
 
> Container(const Item& item) : item(item) {} // copying
> Container(Item&& item) : item(std::move(item)) {} // moving
> };
 
Yes, that's about how it goes.
 
If anything, naming both the member and the constructor parameter with
the same name does not help readability (but works as intended, in the
member initialization list).
David Brown <david.brown@hesbynett.no>: Mar 28 09:10AM +0200

On 27/03/2023 21:08, Scott Lurndal wrote:
 
> Actually, there's something to be said for sticking to the
> portable character set for identifiers, such that the current locale
> and or character set settings don't matter when compiling the source.
 
I think if you are writing modern code, then it is pretty safe to assume
that UTF-8 is fine as a source character set. But you might have to
jump through some option flag hoops to make it work on some Windows tools.
 
There are two real disadvantages to using non-ASCII characters in
identifiers. One is that they can be hard to distinguish in some cases
- which of these is "complement" and which is "capital c"? "∁" "C"
 
The other is a matter of how you type the letters. If you speak Greek
and have a Greek keyboard layout, typing Greek letters for identifiers
is fine - if you have a Norwegian keyboard layout like mine, it's a
pain. I don't know of any layouts with ∀ and ∃ in them - if you use
them a lot, you'll want your own custom compose key combinations. But
even if the code author can get the symbols, people using or maintaining
the code might have trouble.
 
 
Still, we miss out on some fun opportunities when C and C++ only allow
letters, not symbols, in identifiers. It's entirely possible in C++ to
make your own pseudo-operators - identifiers that can be used prefix,
infix or postfix rather than as function calls. So you can make a
vector class and write "a crossproduct b" or "a dotproduct b", but you
are not allowed to write "#define × crossproduct" and "#define ·
dotproduct" to make it nicer in the source code.
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: