I don't even think that's a controversial opinion. Breaking convention isn't inherently bad; it has costs, some of which you described. In this case specifically, the novelty is not justified by any significant benefit.
How so? As the page you linked mentions, simply casting 'const T *' to regular 'T *' is well-defined; it's only modifying a const object through the pointer that's UB (C17 6.7.3/7).
> I don't believe assignments are sequence points and only the function call is.
Assigments within expressions don't create sequence points. However, the expression of an expression statement is a full expression (i.e., not a subexpression of another expression), and there is a sequence point between each pair of full expressions (C17 6.8/4). In other words, the semicolons create sequence points.
To be clear, it's only UB if the object was defined const, which is the case given he wrote:
> One small exception: I still like it as a hint to place static tables in read-only memory closer to the code. I’ll cast away the const if needed.
So you are correct on this point. Funnily enough, such objects are relatively rare IME, so I had to double-check to see that he was advocating it specifically in the rare case where it must not be applied.
Given that this particular undefined behavior usually causes crashes in practice, I expect the author is talking about casting away the const but not actually writing to the pointer. Which is legal.
He never said he needs to cast away const to do what he is attempting to do, he just said that he wants to cast away const to reduce clutter, even though the program would have the same semantics as if he kept the const.
If only there were a way to indicate the function argument isn't mutated. </s>
My spidey senses tingle whenever I see const-ness cast away because it almost always means something is wrong. Either a function is missing a qualifier on an argument, or something very unsafe is happening. Why force callers to cast away const-ness in hopes that everything will be fine when you can just write the correct function signature.
IIRC the golden standard is midnight commander ( https://midnight-commander.org/ ), which is another old timer. I wonder how nnn and vifm compare to mc.
I think the confusion is due to the putty fork that's also called kitty.
wezterm is actually cross-platform and has great support for wsl2 as well. It also comes with a mux component which moves the mux stuff to your local machine and eliminating a lot of issues with running tmux/screen.
I looked into alacritty and kitty as well. Aside from being the best terminal for my needs, wezterm's developer is also pretty friendly and open to issues/PRs and is very responsive. I like the tool and the project so much that I help out with little things like packaging whenever I can.
Thanks for this reminder, I had peeked at wezterm a month or so ago and it sounded slick, but I was pretty happy with my iTerm+tmux setup. Just got a chance to play with wezterm a bit, and I think it's going to be my new term, because:
- The ssh mux seems to work at least as well as mosh+tmux.
- It has decent keyboard Copy/QuickSelect/Search (I liked tmuxes, but didn't get that at my native terminal).
- Runs on MacOS and Linux, my work and home environments.
Yes wez's mux is pretty nice. It will probably get better too. I think it has some mosh-like functionality too. I like that my terminal behaves the same locally and running as muxed domain on a remote server. One less set of shortcuts to remember. If it's not clean I mean for operations like copy/paste yes, but also starting a new tab (which will open a tab in that domain), splitting the current view etc.
Wezterm (kitty too) is really a great piece of software, I use terminals 12 hours a day, but I did not spent a lot of time configure them, but this article is inspirational.
PS: kitty developer is the same developer of calibre, another beautiful software.
That extra scope is an issue for what they're doing, however. They have a macro called "list_for_each_entry()" which syntactically behaves as if it were a "for(...)" (because it is a "for(...)"). To make the extra scope work with that macro, either the user of the macro would have to end the loop with an unbalanced amount of closing braces (to match an extra opening brace within the macro), or it would require a second macro to be used at the end of the scope. Keep in mind that this macro is used in literally thousands of files within the kernel.
Sure. This may not be a feasible approach for this case. I'm just pointing out alternative approaches to mitigate this kind of scoping problem in C89. Maybe wrap every use of list_for_each_entry in braces?
Then you get dinged by static analysis tools like SonarQube because you introduced a useless scope or increased the "cognitive complexity" to the code and have to explain it to a team leader who might not understand why you did that.
- https://neovim.io/doc/user/pi_paren.html - https://neovim.io/doc/user/lsp.html#lsp-highlight