All that is missing is a garbage collector. Should be possible to implement one by overriding malloc & friends?
Pretty.c
51–60 of 227 posts
Re: Pretty.c
#52Re: Pretty.c
#53Earlier quoted context omitted.
Another bikeshed is the infinite for(;;) loop being called "always" I've seen "loop" in other languages. But Qt calls it "forever", and that is indeed very pretty. Very Qt, even
> I've seen "loop" in other languages. But Qt calls it "forever", and that is indeed very pretty. Very Qt, even You can break a "forever" loop so I think "loop" is a better name.
repeat {}
repeat while {}
repeat {} while
repeat {}Re: Pretty.c
#54Earlier quoted context omitted.
Wow, I was not expecting that! Was this style of C common back then? Before he wrote the Bourne shell the author wrote an ALGOL compiler, and ALGOL inspired Bourne syntax: https://en.wikipedia.org/wiki/ALGOL_68C
There were article suggesting #define BEGIN { and #define end }; to make C look more like Pascal. I think in Europe C was not as common as other languages at the time so the terseness looked odd.
Characters like []{}\|~ are behind multi-finger access and often not printed at all on the physical keys (at least in the past). You can see how this adds a hurdle to writing C…
Pascal was designed by a European, so he preferred keywords which could be typed on every international keyboard. C basically just used every symbol from 7-bit ASCII that happened to be on the keyboards in Bell Labs.
Re: Pretty.c
#55Earlier quoted context omitted.
https://en.wikipedia.org/wiki/Stephen_R._Bourne https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh
Now that's just silly. And I see the backwards keyword terminators (LOOP/POOL). I have wondered why we have case/esac, if/fi but while/done. I imagine the author himself figured that while/elihw would just be entirely ridiculous.
Re: Pretty.c
#56`equal(0.3, 0.2 + 0.1); // true` how is this wizardry possible?
It uses type dispatch to perform an epsilon comparison: static int pretty_float_equal (float a, float b) { return fabsf(a - b) So it’s https://docs.python.org/library/math.html#math.isclose
FLT_EPSILON is the difference between 1.0 and the next larger float. It's impossible for numbers less than -2.0 or greater than 2.0 to have a difference of FLT_EPSILON, they're spaced too far apart.
You really want the acceptable error margin to be relative to the size of the two numbers you're comparing.
Also, everyone should read the paper "What, if anything, is epsilon?" by Tom7
Re: Pretty.c
#57Re: Pretty.c
#58Re: Pretty.c
#59Earlier quoted context omitted.
Another bikeshed is the infinite for(;;) loop being called "always" I've seen "loop" in other languages. But Qt calls it "forever", and that is indeed very pretty. Very Qt, even
> I've seen "loop" in other languages. But Qt calls it "forever", and that is indeed very pretty. Very Qt, even You can break a "forever" loop so I think "loop" is a better name.