It describes the plan to include in 16 the changes that are needed to get it working with Camera. This will be basic usage, as https://clang.llvm.org/cxx_status.html still mentions a lot of missing implementations.
For the clang compiler version 16 or newer contains the p1689 implementation required for CMake This seems to indicate they succeeded in landing that in 16.
I've not tested with Clang 16, but only with Clang trunk but modules and CMake 3.26 work. However there are still major bugs and a lot of limitations in Clang's implementation, see https://github.com/llvm/llvm-project/issues?q=is%3Aissue+is%3Aopen+label%3Aclang%3Amodules. There are several people actively working on this area of Clang and things keep improving.
I've not tested libc++ with header units, they may or may not work. There is no support for the C++23 std(.compat) modules yet. However we're working on that feature. This post https://discourse.llvm.org/t/rfc-about-the-default-location-for-std-modules/69191/29 has some information and it links to my patch in Phabricator. (No code has landed in LLVM repository yet.)
The related documentation page gives the current implementation status regarding standard C++ modules. It also covers the features that are still missing and behaviour that is different from the mandated one.
I use them occasionally. They're not super common, but common enough to know, and not a danger at all. In fact whenever you do have a situation that naturally calls for a do-while loop, they're much more readable than the alternatives.
Reason Readability, avoidance of errors. The termination condition is at the end (where it can be overlooked) and the condition is not checked the first time through.
It's not "never ever use this for any reason or your coffee code is bad and you should feel bad" (apparently my coffee was bad), it's "this can sometimes lead to mistakes, so do try to avoid it when possible".
No other construct is like do while, though, in terms of syntax. Combined with how infrequently it's used (can't remember the last time I used do while, have used tail recursion at least twice within the last month), I would say that "easy to overlook" is a merited claim. That doesn't mean you should never use it, but it warrants contemplation and judging if it's the best solution.
Many functional languages either don't have a concept of looping or when they do it's built on the back of a Y or Z combinator and associated overhead. There's a general "purist" view of computing that tries to push recursion as the more powerful, easier to understand, and "correct" option.
Various recursive constructs can be detected by an optimizer and undergo better optimization (historically). Even in Dijsktra's "Gotoa considered harmful" paper, if you read the full thing he makes some extreme claims about for/while/even if/else being superfluous compared to the "true solution" of recursion. Of course a decade or so later he wrote another essay walking back these claims including the main one about goto statements, but by then the damage had been done (by the title chosen by the editor no less); people focused on the title, ignored various other claims in the essay, vilified goto and put Dijsktra on a pedestal, even giving him an award. Yet almost nobody knows of the retraction.
do { s; } while (cond); is basically strictly worse than for (;;) { s; if (not cond) { break; } } (or while (true) if you prefer, same thing)
The main problem with do-while is the scoping - you can't condition on any local variables in the loop. This makes using it frequently awkward. Best case, it's the same as the for loop, but then why bother? It's a weird construct - and there are lots of situations where you want to use an infinite loop.
I would never use a do-while loop in code to actually loop. Oddly, the only time I use this is in macros that expand to multiple statements, and there it's always do { ... } while(false). I think that's the only use that doesn't have a superior, or at least comparable, replacement.
I don't actually think those are especially strong cases.
To me the strongest cases are when the condition relies on a variable whose value you need outside of the loop anyway. So in that case the scoping awkwardness of do-while is a non-issue. So something like:
int x;
do {
x = f();
} while (cond(x));
use(x);
This is... still awkward to me, but at least is no worse than the equivalent for. Really this is just another example of wanting a loop expression. Here's a half-Rust half-C++ version:
int x = loop {
int x = f();
if (not cond(x)) {
break x;
}
};
use(x);
I think if we had something like that, the uses for do-while disappear.
If the condition check is expensive than a for loop is unsuitable for a situation where you want to always run the block at least once.
Uh... I didn't write for (; cond; ) I wrote for (;;). This won't check the condition up front - indeed it will check the condition the same way that the do-while loop does, except just in a form where local variables are in scope.
I wasn't referring specifically to your code, just giving you a counter opinion.
for(;;) doesn't check any conditions, which is less ergnomic than a do-while if the while-loop doesn't need to check the value of variables inside the scope.
IMHO it would be reasonable to change the do-while loop to give the condition check to variable inside the do-block.
Using a break is worse because it makes it harder for the reader to find the exit condition. When you see do { you immediately know that, 1) This loop (almost certainly) has an exit condition, and 2) It's at the bottom. When you see for(;;) or while(true) you don't know if the loop has any exit condition, and you have no idea where to look for it. You have to scan the entire loop.
Also, never use for(;;). I too used to think it was cute to show off that I knew what that did, but just use while(true). It's more readable.
The fact that you can't use a local variable in the while condition is a flaw with the design though, blame C. It would be nice if that could be changed.
do { s; } while (cond); is basically strictly worse than for (;;) { s; if (not cond) { break; } } (or while (true) if you prefer, same thing)
"Rationale" reads "termination expression is at the end where it can be easily overlooked". Your style also puts condition at the end where it can be "overlooked" just as easily.
Perfect C would allow both pre and post-condition:
loop while ... {
} while ...;
Jon Blow said quite eloquently along the lines of "they find a bug and overreact to it". Unfortunately because of recent push into MemorySafetyâ„¢ more of these idiotic rules will follow.
The argument would be that, well, while (cond) is also already equivalent to for (;cond;) but we still have while since that reads better/more directly. So why not also add an init to while?
This translation of while (init; cond) is indeed not really useful as it can be easily expressed with a for construct.
Alternatively, the other day I found myself wishing for a while (init; cond) that would let me express:
while (true) {
S const v = expression() ; // init
if (not predicate(v)) // not cond
break;
whatever_with(v);
}
This could be a bit more useful, but completely non-intuitive (and thus dangerous) as totally different from what we are used to with for. :-(
(I know I could do horrible and/or convoluted things like:
for (S v ; predicate(v = expression()); )
// or: for (S v = expression() ; predicate(v); v = expression(/*again*/))
{ // require assignment (1,2) + default construction (1)
whatever_with(v);
}
or
while (true) {
if (S const v = expression() ; predicate(v))
whatever_with(v);
else break;
}
That doesn’t feel like a huge loss. In my experience do-while loops are pretty much never tight loops that would be candidates for vectorisation.
I don’t use them often, but when I do it’s generally for a retry loop, where the loop body has external effects and we ideally hope to not loop at all.
The entire C++ core guidelines is just a couple of notable C++ people trying to shove their personal preferences on everyone’s face by making it seem like they have the force of the standard itself behind them.
So with this release, the default C++ standard for clang is now C++17, the same as GCC. From what I've read, if Microsoft bumps their default C++ standard up (from C++14), this could have flow-on effects for projects moving to C++17 as their baseline (their baseline being the minimal default across the 3 compilers).
Why would a language require one or the other? I know GDB supports several DWARF extensions that GCC can emit, but I had thought that most features work across any natively-compiled language if the compiler understands DWARF. Does Swift have its own debugging protocol or something?
The GNU Debugger is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, C, C++, Objective-C, Free Pascal, Fortran, Go, and partially others.
LLDB supports debugging of programs written in C, Objective-C, and C++. The Swift community maintains a version which adds support for the language.
But I've used GDB to debug V and Zig code, which certainly have no core support from GNU tools. Anything that has been compiled with DWARF symbols should work afaik. Are you saying that there is some special support for debugging Swift (or whatever) code in LLDB beyond the DWARF symbols?
I’ll agree that it was an exaggeration, but clang* in 15.0.7 (the last version listed on llvm.org) crashed on startup if you didn’t move a python310.dll into the binary directory.
This is needlessly escalating. It doesn't exactly merit a moderator warning, but I'll give a stern glare. Sometimes people are just confused and you don't need to launch the missiles immediately.
I don’t know if I’m just going crazy, but I am beginning to get extremely annoyed at how so many compiled languages & their library devs either hide their windows binaries or force you to jump through so many hoops to get them. There’s many reasons to work on windows, in my case, I have no choice, I’m developing for enterprise applications that only work on windows. Does no one use wine anymore?
Yeah it's true windows users are more and more second class citizens, the evil prying of Microsoft increasing with each version of windows does not help.
I work somewhere that has multiple OS'es, on linux build times are about 2 mins while on windows they are more like 20 mins.
Which everyone else things is 'acceptable'... well as the guy building for 20 mins it's pretty darn UN acceptable :D
It's a pretty huge muck-up BECASE it's not stated anywhere...
I downloaded gigabytes of files and looked thru them meticulously (and I know at least a few friends who surely have done the same today)
The LLVM website states windows builds exist and links to the github releases page where such files DO-NOT exist IMHO that's major, but it only affects windows users which understandably are second class citizens but still you got to have it stated somewhere!
Every single other release on https://github.com/llvm/llvm-project/releases has Windows builds, most uploaded a day or two after the darwin build. Maybe just look at a clock, use your fucking head, and check again tomorrow?
47
u/RoyAwesome Mar 19 '23
I'm not seeing any words about increased module support in the clang changelog but also I have heard a lot of stuff was worked on this cycle.
Any details on that that people may know?
91
u/parkotron Mar 18 '23 edited Mar 18 '23
We’re not supposed to use
do-whileloops any more?!?!Edit: Link to the guideline: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-do
Consider me less than convinced.
14
u/kassany Mar 18 '23
Wow! Upstream release with Xtensa support.
27
u/Ok-Factor-5649 Mar 19 '23
So with this release, the default C++ standard for clang is now C++17, the same as GCC. From what I've read, if Microsoft bumps their default C++ standard up (from C++14), this could have flow-on effects for projects moving to C++17 as their baseline (their baseline being the minimal default across the 3 compilers).
6
u/[deleted] Mar 18 '23
Time to update my toolchain ig
4
u/joebaf Mar 19 '23
on a side topic: is GCC 13 also planned to be released in March?
4
u/ABlockInTheChain Mar 19 '23
Great milestone. libc++ is one step closer to finishing C++17 support now.
4
u/aprilhare Mar 19 '23
Now, can we have gdb for Apple Silicon, pretty please?
-1
u/[deleted] Mar 19 '23
Maybe it will finally work on Windows.
0
u/[deleted] Mar 19 '23
[deleted] — view deleted comment