Live data from Hacker News

The Ugliest C Feature: tgmath.h

web.archive.org

11–20 of 24 posts

Re: The Ugliest C Feature: tgmath.h

#12

The ternary operator is indeed special as it (is the only one AFAIK that) introduces in the language some type constraints between the two result branches, that affect the way one or the other is interpreted. A similar trick in C++ is explained on https://www.artima.com/cppsource/foreach2.html and allows to return the type of an expression without evaluating it . From the link: > You may be thinking this is needlessl…

That sort of operator is often tough, just look at section 15.25 in the Java language specification (https://docs.oracle.com/javase/specs/jls/se13/html/jls-15.ht...) in the type of such expressions.

Re: The Ugliest C Feature: tgmath.h

#16

The ternary operator is indeed special as it (is the only one AFAIK that) introduces in the language some type constraints between the two result branches, that affect the way one or the other is interpreted. A similar trick in C++ is explained on https://www.artima.com/cppsource/foreach2.html and allows to return the type of an expression without evaluating it . From the link: > You may be thinking this is needlessl…

Qt apparently does something similar to implement Q_FOREACH: https://stackoverflow.com/a/10522384/5230900

That was pre-c++11. Now using C++11, it is much simpler (using 'auto'). And the C++17 version is even simpler

https://code.woboq.org/qt5/qtbase/src/corelib/global/qglobal...

Re: The Ugliest C Feature: tgmath.h

#17

With apologies to Philip Greenspun: Any sufficiently complicated C program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of C++.

Sure, but the C++ STL is to code as this [1] is to knives.

[1] https://www.amazon.com/Wenger-16999-Swiss-Knife-Giant/dp/B00....

Re: The Ugliest C Feature: tgmath.h

#20

With apologies to Philip Greenspun: Any sufficiently complicated C program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of C++.

Sure, but the C++ STL is to code as this [1] is to knives. [1] https://www.amazon.com/Wenger-16999-Swiss-Knife-Giant/dp/B00... .

For the low low price of $9999.99.

Is that the maximum you can charge on Amazon? Seems strange that they'd want to put a limit on it.

Post reply on HN