Re: Common Lisp solved this problem 20 years ago Per Bothner 27 Oct 2005 00:20 UTC

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.  And sometimes people can compile
in "unsafe" mode, just as with the Common Lisp model.

> More to the point, I object to the use of a type declaration which
> also signifies an operation.  Among other things, you lose one of the
> timing benefits of the type declaration.  Why not separate these two?
>
> Maybe you're using "declaration" to mean something wildly different
> from the Lisp meaning.

It is somewhat different, yes.  I'm not proposing "type
declarations" in the Common Lisp sense.  I use the word "declaration"
in the more usual "variable declaration" sense.  I'm adding optional
"type specifiers" to "variable declarations".
--
	--Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/