Plaster

text
17:42 < phoe> rme: I need some help to fix a LOOP bug from ANSI-TEST. 17:43 < phoe> I need something that will let me circumvent SAFETY 3 typechecks - basically, something that will allow me to set a variable to a value that is not of the declared type. 17:43 < phoe> The issue is visible at https://plaster.tymoon.eu/view/1535#1535 17:43 < phoe> Line 11 sets X to 6 at some point, but X is of type (INTEGER 1 5). This signals an error in safe code. 17:44 < phoe> A possible fix (that e.g. ECL does) is to circumvent type-checking around the SETQ. 17:45 < phoe> It does it via a custom local declaration at https://gitlab.com/embeddable-common-lisp/ecl/blob/develop/src/lsp/loop.lsp#L80 17:45 < phoe> I wonder if something similar is available in CCL. 17:50 < phoe> Oh! I can locally declare safety 1 and the SETQ works. 17:50 < phoe> Let me try this... 18:16 < pjb> I would think that (let ((x 1)) (declare (type x (integer 1 5))) (locally (declare (type x (integer 1 6))) (setf x 6))) would be very unsafe. 18:17 < pjb> By the first declaration, an implementation would be entitled to allocate storage only for (integer 1 5) for x. The local declaration is wrong, and the setf even more wrong and it could be fatal. 18:18 < pjb> ie. Don't play with declarations like that! You're not writing C code! 18:21 < phoe> pjb: OK - therefore I'll need a better declaration. (And an explanation for why the ECL variant works) 18:22 < pjb> Lying to the compiler can only give implementation dependent results. 18:23 < phoe> pjb: In this scenario, I *am* the compiler. Or rather, I am the implementation - I am already working behind the scenes. 18:23 < pjb> The only correct solution, once you have a type declaration on the loop variable, is to use another internal loop variable! 18:24 < pjb> Or to be smart and extend the type: (integer 1 5) -> (or (integer 1 5) (integer 6 6)) or something like that. 18:24 < phoe> pjb: that would mean that ECL is broken in this regard, too 18:25 < pjb> At least, it's brittle, since the macro expansion depends on some behavior from the compiler. Already, we have 2 compilers (byte-code and C), and other compilers could be introduced…