On Tue, Jul 8, 2025 at 7:50 PM Rob Landley <r...@landley.net> wrote: > > On 7/8/25 15:44, Alejandro Colomar wrote: > > [CC += wg14] > > > > Hi Elliott, Rob, > > > > On Tue, Jul 08, 2025 at 03:32:37PM -0400, enh wrote: > >> On Tue, Jul 1, 2025 at 1:52 PM Rob Landley <r...@landley.net> wrote: > >>> I spent many years figuring out what I could throw away. That quote from > >>> the guy who wrote "The Little Prince" was my email sig for a while: > >>> > >>> https://www.goodreads.com/quotes/19905-perfection-is-achieved-not-when-there-is-nothing-more-to > > > > [...] > > > >>>>> it's been implemented by clang/gcc for a long time, but if you're > >>>>> going to be a standards lawyer about it, __has_include() is c++17 and > >>>>> c23. > >>> > >>> Sigh. Did one of the standards finally include gcc's empty ? : middle > >>> argument? (Which I use all the time...) > >> > >> c23 does not include this, and i don't think i've seen a proposal to > >> standardize it. +Alejandro Colomar pays more attention to wg14 though, > >> so he might know better... > >> > >>> Sadly, standards remain a frame of reference to diverge from... > > > > I've written a proposal for standardization of that. So far, I've only > > presented it informally (via email) to the committee, but I'll turn it > > into a proper paper after the next meeting that will be in August. > > > > Here's my draft proposal: > > <https://www.alejandro-colomar.es/src/alx/alx/wg14/alx-0030.git/tree/alx-0030.txt> > > (Anyway, I've pasted it at the bottom of the email, for convenience.) > > > > In August, we'll vote a proposal on which mine depends for the wording, > > which is why I didn't yet present an N document. > > > > I've CCed the committee in this email, so that they see that people are > > interested in having this feature and use it all the time. > > > > Feel free to comment on the proposal, if you think you'd add anything to > > the rationale. > > Rationale? As in why I was surprised this wasn't in C11?
(fwiw, in terms of "is this used much?" there are a thousand different _files_ in the Android source tree where ?: is used in c [i deliberately didn't count c++, nor any matches in clang/llvm, where it's hard to distinguish legit uses from implementation/tests]. since most google-written source is c++, this means that over 950 of those files are from third-party open source c projects we pull in.) > The linux 1.0 kernel circa 1994 used the ? : operator 4 times in > fs/pipe.c (which is not optional, that's a core file part of all builds > no matter the target or configuration). This stayed the only uses for > 1.2 and 2.0, but in 2.2 (1999) it expanded to 31 uses in multiple files. (someone should fix the wikipedia page which only has "at least 2001" for gcc :-) ) > When Intel extended its proprietary ICC to build Linux 2.4.21 (ala > https://community.intel.com/legacyfs/online/drupal_files/article/146679/linuxkernelbuildwhitepaper.pdf) > the ? : operator was one of the things they added support for (although > the name "elvis operator" hadn't been coined yet, > https://web.archive.org/web/20170830022856/https://software.intel.com/sites/default/files/m/d/4/1/d/8/Intel_Linux_Compiler_12_01_GNU_Compatibility_rev10.pdf > called it "conditionals with omitted operands".) > > When tinycc built a 2.4.26 kernel ala > https://bellard.org/tcc/tccboot.html back in 2004 it also had to support > empty "? :". > > By the time Clang/LLVM built a Linux 2.6.36 in 2010 > (https://lwn.net/Articles/411654/) support for ? : was a well-known > requirement for building Linux and linux programs like busybox (release > 1.2.2 in 2006 had 9 instances). > > Even small compilers like libfirm/cparser support this (ala yeah, chibicc too: https://github.com/rui314/chibicc/blob/main/parse.c#L2185 > https://github.com/libfirm/cparser/commit/315d496108eb from 2007) and I > just built a quick test program with the current > https://github.com/PortableCC/pcc to confirm that supports it too > (although the git repository history only goes back to 2002, beginning > with a single "import" commit flattening the earlier history, so if > there was a specific commit mentioning ? : in its description it was > before then.) I believe that's the compiler that FreeBSD switched to > clang from? > > All of that predated C11. FreeBSD and MacOS support ? : just fine in a > simple "cc hello.c" using the stock host $PATH, no homebrew required, no > idea when they last _didn't_. > > IBM's big iron tech all started soaking up serious linux-isms in 2001 > with Gerstner's "billion dollars a year on linux" announcement, long > before they were reverse-acquired by Red Hat, and I believe this was one > of them all the way back then. The OS/2 development staff consolidated > from Boca Raton to Austin in 1996 became the core of the IBM Linux > Technology Center 5 years later, AIX 5L was also 2001, Linas Vepstas' > "bigfoot" port of Linux to the 360 was 1998 ala > https://linas.org/linux/i370-why.html ... > > As always, I have no idea what Windows is doing. > > Rob > > P.S. I don't know where the name "Elvis operator" came from. Page 11 of > https://github.com/CppCon/CppCon2019/blob/master/Presentations/nonconforming_cpp/nonconforming_cpp__miro_knejp__cppcon_2019.pdf > also calls it "conditionals with omitted operands", and 6 minutes into > https://www.youtube.com/watch?v=IAdLwUXRUvg the guy giving that > presentation calls it that and then boggles at the name "elvis > operator". I think the email this is replying to is second time I've > ever heard anyone call it that, and vaguely assumed it was some sort of > pun on vi using colon commands a lot. yeah, i don't hear it much amongst c programmers, but it's common to call it that in _other_ languages. _______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net