libera/#commonlisp - IRC Chatlog
Search
18:30:15
pve
Is one supposed to use (the double-float ...) or (coerce ... 'double-float) to tell the compiler what to expect?
18:34:43
mfiano
The former is a promise to the compiler, which is allowed to do nothing or anything.
18:35:05
lotuseater
hm i thought with THE it's more like a promise "this shall be that type" and with coerce an instruction "transforms this to the new type"
18:37:03
aeth
(the double-float x) is very, very, very close to (prog1 x (check-type x double-float))
18:38:03
aeth
SBCL doesn't. For DECLARE, DECLAIM, THE, etc., SBCL will use a faster CHECK-TYPE that is not recoverable.
18:39:31
aeth
What I mean is, (prog1 x (check-type x double-float)) in SBCL will let you supply a new x that satisfies double-float, while (the double-float x) will fail the program if it's not a double-float
20:24:45
pjb
pve: (the double-float x) (or (declare (type double-float x))) is actually more like: { int x; *(double*)&x=3.14d0; }
20:25:37
pjb
pve: (coerce x 'double-float) is more like {int x=314; (double)x; } this can be acceptable.
2:36:59
aeth
pjb: Not really. Only SBCL with (safety 0) will possibly behave like you're talking about in practice. If you do want that sort of { int x; *(double*)&x=3.14d0; } behavior you can get it, via abusing the CFFI
2:54:36
aeth
(pointless in that THE could behave many different ways, so there's always a better way to get the desired behavior in a more precise, specified way)
2:59:19
lotuseater
one told me that even more the good data structures were responsible that Quake 3 ran performant on small machines :)