Re: Common Lisp solved this problem 20 years ago
Thomas Bushnell BSG 27 Oct 2005 03:19 UTC
Per Bothner <xxxxxx@bothner.com> writes:
> Thomas Bushnell BSG wrote:
>> I thought the primary semantic of a type declaration was that it told
>> the compiler what type the variable would be used to hold. Now you
>> also are using it for something other than a declaration, viz., a
>> particular operation.
>> Among other things, it slows things down because you have to test the
>> result of the init to see whether coercion is necessary.
>
> Not necessarily. Sometimes the compiler can infer that the
> coercion is a no-op or trivial.
Sure, but in a great many of those cases, the compiler might not need
the declaration anyway. :)
> And sometimes people can compile
> in "unsafe" mode, just as with the Common Lisp model.
But then compiling in unsafe mode now changes the behavior of the
program, even correctly behaving programs, because if it turns off the
coercion, the semantics of the program change, right?