foo({.x=2, .y=2}) I remember using this syntax in C in my 2017 project. This is very clear to call methods like that, I used it with minor #defines, i found the inspiration in the book "21st century C."
Fun with C++26 reflection: Keyword Arguments
121–130 of 147 posts
Re: Fun with C++26 reflection: Keyword Arguments
#122Earlier quoted context omitted.
That list would be like saying "Java on Android". A single platform's narrow usage of a language != language's standard library having it.
It is the standard library on the platform, of course it counts. Get Smalltalk-80 reference manual without the UI documentation of its standard library, and no, GNU Smalltalk is not a complete implementation.
Re: Fun with C++26 reflection: Keyword Arguments
#123Earlier quoted context omitted.
https://javascriptwtf.com/ Arguably this is worse than C++ because for basic things/beginner to intermediate users, the footguns in C++ are more benign (e.g. performance related, rather than correctness) than the ones in JavaScript.
> the footguns in C++ are more benign I don't think I can agree. https://pvs-studio.com/en/blog/posts/cpp/1215/
Now that I think about it, the fact that you necessarily have to use a compiler with C++ is also part of the equation here. It's basically a mandatory linter. With JavaScript as with any interpreted language there's a lot of mines you can trip over waaaaaay down the line, especially if you aren't taking steps to use linters.
Re: Fun with C++26 reflection: Keyword Arguments
#124Earlier quoted context omitted.
https://javascriptwtf.com/ Arguably this is worse than C++ because for basic things/beginner to intermediate users, the footguns in C++ are more benign (e.g. performance related, rather than correctness) than the ones in JavaScript.
The same tired edge cases. Especially the null pointers. Yes, but what did you want the language to do? Stop you? You can do that yourself.
Re: Fun with C++26 reflection: Keyword Arguments
#125Earlier quoted context omitted.
We don't even write utilities in JVM languages, because spawning whole JVM is generally considered too expensive. Yet there are people who will happily spawn whole web browser and even go as far as recommend doing so. All because they can't even write a left-pad function.
> We don't even write utilities in JVM languages, because spawning whole JVM is generally considered too expensive. This is definitely not why, at least today. People are even willing to spawn an entirely new userspace (docker) for their utilities. > Yet there are people who will happily spawn whole web browser and even go as far as recommend doing so. Electron, like the JVM is nice and cross-platform with no BS. The…
If we were talking in person I'd look at you like you had 2 heads now. In my bubble it is extremely en vogue to hate on Electron being a piece of bloated shit…
…but then again, I will agree that this is a piece of social signaling and would need some actual evaluation. There's probably some real problems with Electron that have caused people to start hating on it, but who knows how relevant those are. Trivial junk can easily snowball into social signals like this.
Re: Fun with C++26 reflection: Keyword Arguments
#126But some of these new features… I feel like they're a bit desperate attempts at fitting in with the kids.
Not to start a language war, but I don't see how any attempt at stapling modern features onto C++ make it a good choice in 2025. There are at least two viable plug in replacements, that have good interop.
Like I said, I've coded C++ for 30 years (along with other languages, sure), so I'm not a fad follower. I don't say it lightly, but I do say that coding C++ in 2025 means creating technical debt. And these features won't change that.
Re: Fun with C++26 reflection: Keyword Arguments
#127foo({.x=2, .y=2}) I remember using this syntax in C in my 2017 project. This is very clear to call methods like that, I used it with minor #defines, i found the inspiration in the book "21st century C."
you do have to cast it, though: `foo((vec2){.x=2, .y=2})`
the oldest MSVC on godbolt also accepts it, so it should be very portable as long as you're not using some embedded compiler from the mid 90s
a related fun thing is that you can pass it by pointer, and the lifetime will extend until the function is done:
`foo(&(vec2){ .x=2, .y=2 })`
Re: Fun with C++26 reflection: Keyword Arguments
#128foo({.x=2, .y=2}) I remember using this syntax in C in my 2017 project. This is very clear to call methods like that, I used it with minor #defines, i found the inspiration in the book "21st century C."
i believe this is standard since c99 you do have to cast it, though: `foo((vec2){.x=2, .y=2})` the oldest MSVC on godbolt also accepts it, so it should be very portable as long as you're not using some embedded compiler from the mid 90s a related fun thing is that you can pass it by pointer, and the lifetime will extend until the function is done: `foo(&(vec2){ .x=2, .y=2 })`
Re: Fun with C++26 reflection: Keyword Arguments
#129Earlier quoted context omitted.
> We don't even write utilities in JVM languages, because spawning whole JVM is generally considered too expensive. This is definitely not why, at least today. People are even willing to spawn an entirely new userspace (docker) for their utilities. > Yet there are people who will happily spawn whole web browser and even go as far as recommend doing so. Electron, like the JVM is nice and cross-platform with no BS. The…
> Electron, like the JVM is nice and cross-platform with no BS. If we were talking in person I'd look at you like you had 2 heads now. In my bubble it is extremely en vogue to hate on Electron being a piece of bloated shit… …but then again, I will agree that this is a piece of social signaling and would need some actual evaluation. There's probably some real problems with Electron that have caused people to start hat…
I was just bringing up the similarity in ease of packaging.
Re: Fun with C++26 reflection: Keyword Arguments
#130I just don't understand why some people are so fascinated by this. Can you all admit that this is not at all practical? I swear C++ folks like it for the sake of it. No other engineer do this. Only antiques people or whatever. Can you imagine an engineer that is adamant on using his mystifying bespoke tool instead of just using a ruler. "But what if I have to measure it in the 4th dimension!?". I was expecting someth…
This is a nifty little gadget, not a production level feature. C++ lacks a lot of things, but it's objectively cool that you can hack some of them yourself (like kwargs). No one should use this in important code. This is just fun.