[pro] [imp-hackers] Declarations in compilers (feedback welcome)
Juan Jose Garcia-Ripoll
juanjose.garciaripoll at googlemail.com
Thu Dec 29 14:04:48 UTC 2011
On Thu, Dec 29, 2011 at 1:33 PM, Nikodemus Siivola <
nikodemus at random-state.net> wrote:
> On 29 December 2011 12:24, Juan Jose Garcia-Ripoll
> <juanjose.garciaripoll at googlemail.com> wrote:
> > - Type declarations are always believed
> > - SAFETY >= 1 adds type checks to enforce them.
> > - SAFETY = 0, no checks.
> > - SAFETY = 1, the special form THE or additional proclamations on the
> > functions can be used to deactivate the check. As in (LET ((Y (THE FIXNUM
> > (FOO X))) ...)
>
> I somewhat dislike making THE a loophole [...]
> CMUCL has the equivalent as EXT:TRULY-THE. You may want to consider
> something like that as well. [...]
> At the end, as long as SAFETY 0 = trust everything blindly and SAFETY
> 3 = check everything, I think you're well within the bounds of custom
> and sanity if you choose to make SAFETY 1 a bit magical.
I believe there can be a compromise between safety and speed. There are
many macros and user code that can perform assertions about the code that
the compiler will never be able to, and it is in my opinion unfortunate
that all the safety checks have to be removed to take full advantage of
those.
I also understand that some of the type checks are cheap, specially if the
compiler is allowed to "simplify" them, as SBCL does for SAFETY=1, but the
result is code bloat. Lots of avoidable checks, branching and error
messages that we could do without, without actually sacrificing safety.
That does not seem like a bad case for something in between both extremes.
Conceptually, in the model above, I do not see the THE as a loophole, but
rather as two different things: variable declarations = type checked
assignments, value declarations = compiler hints. For instance, if I invoke
a function with a THE argument, SBCL will not generate a check: (FOO (THE
FIXNUM X)) is just (FOO X), am I wrong? (I just checked in Ubuntu's SBCL)
Then in that sense THE does not really make much sense at all, because the
type checks are introduced by assignments to variables, not by this special
form.
Juanjo
--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/pro/attachments/20111229/7bf72192/attachment.html>
More information about the pro
mailing list