News for hackers. Stuff that matters.
Re:Learning that you can use unions in C for grouping things... by shaklee3 on Monday August 02, 2021 @01:10AM (#28033127)
Can you link to it? We're using expression templates on a new library and I find it useful.
Re:Learning that you can use unions in C for grouping things... by acehreli on Tuesday August 03, 2021 @01:01PM (#28051524)
I don't know what code Walter is referring to but I had similar experiences during a presentation of the Boost Spirit library (at our Silicon Valley C++ Meeting; must be about a decade ago now).

The speaker was proud and beaming for showing how powerful C++ is and the audience was in awe.

I was incredulous! Jaw open! The "solution" was horrible with a bunch of workarounds for a bunch of shortcomings. It was a "the emperor does not have cloths" moment for me.

Boost Spirit may be better today with newer C++ features; I don't know.

Re:Learning that you can use unions in C for grouping things... by shaklee3 on Tuesday August 03, 2021 @01:09PM (#28051628)
That's kind of the key. We require c++17. Without that it gets extremely ugly and more verbose.
Re:Learning that you can use unions in C for grouping things... by WalterBright on Monday August 02, 2021 @03:27AM (#28033835)
Oh man, you sure know how to drive a stake in my heart! What have I done! Some curses should just not be uttered. I'm not sure where it is on my backups.

But it was done just like you'd do it in C++. The same thing, just with D syntax.

Re:Learning that you can use unions in C for grouping things... by shaklee3 on Monday August 02, 2021 @09:11AM (#28036051)
We're making a numerical computing library that expression templates are used for compile-time evaluation of expressions. It's a very niche hpc library, so it might be one of the few places it's appropriate.
Re:Learning that you can use unions in C for grouping things... by WalterBright on Monday August 02, 2021 @07:35PM (#28044056)
I wish you luck with it. If you send me an email, when I find what I wrote about it I'll pass it along to you.
Re:Learning that you can use unions in C for grouping things... by 1980phipsi on Tuesday August 03, 2021 @01:08PM (#28051618)
They probably aren't the only people interested in that...