sharplispers / clx

a fork of crhodes' fork of danb's fork of the CLX library, an X11 client for Common Lisp
Other
114 stars 46 forks source link

anglep: inline radians->int16 operation #164

Closed dkochmanski closed 4 years ago

dkochmanski commented 4 years ago

RADIANS->INT16 declares, that the argument is of the type ANGLE. Some implementations when declared put check-type, and the type ANGLE is declared as (SATISFIES ANGLEP). Then, ANGLEP called RADIANS->INT16 internally what lead to infinite recursion.

JMC-design commented 4 years ago

Perhaps declare a pi constant and use the type in clx.lisp. Using a slightly wider definition of pi to encompass implementation differences can't be worse than the larger values this definition already lets through. But since this is an override, if a specific implementation is having problems with the circularity maybe just remove them from the inclusion?

dkochmanski commented 4 years ago

pi may be passed from a client library (i.e from outside the xlib package). This override makes it that encoding of the value in x11 protocol fits in the boundaries, so it seems to be the right thing to do. Inlining the conversion seems to solve the problem, and since we know the reason why, we know that it will solve it for any implementation which does the same thing (that is -- expands declarations into type checks).

JMC-design commented 4 years ago

What is the point of overriding the definition in clx.lisp? Why not have one definition? The wire doesn't actually care and will happily accept anything.