Live data from Hacker News

Pretty.c

github.com

91–100 of 227 posts

Re: Pretty.c

#91

I've seen this implementation of defer a few times now. I really dislike calling this defer (like the keyword in Go) as the given code won't be executed on return.

Scoping defer to a block is actually more useful and explicit than function-exclusive that Go does, so I consider that a feature.

Re: Pretty.c

#94
post #73
post #72

Earlier quoted context omitted.

Today I learned that there exist people who use non-US layouts when coding. That’s spectacular!

How did you think people outside the US learn programming?

              setxkbmap us -option ctrl:swapcaps -option compose:rwin
Problem solved. US layout, and with the right Window keys you can compose European characters.

Re: Pretty.c

#95
post #56

Earlier quoted context omitted.

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

This code is incorrect, but I don't blame them. :) Probably one of the most common float-related mistakes, even among people who "know how floats work". 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 si…

Indeed, FLT_EPSILON is not a one-size-fits-all solution, but it's good enough for frequent case of comparing big enough numbers, which is not covered by regular ==. So it's a convenience/correctness trade-off I'm ready to make.

Re: Pretty.c

#99
post #36

This made me immediately think whether MIT Loop of Common Lisp was an inspiration here. Checked the user's profile and sure enough, a lisper!

Yes, LOOP is a huge inspiration and my favorite programming language!
Post reply on HN