[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Common Lisp solved this problem 20 years ago

This page is part of the web mail archives of SRFI 77 from before July 7th, 2015. The new archives for SRFI 77 contain all messages, not just those from before July 7th, 2015.



Per Bothner <per@xxxxxxxxxxx> writes:

> Thomas Bushnell BSG wrote:
>> Per Bothner <per@xxxxxxxxxxx> writes:
>>
>>>Taylor Campbell wrote:
>>>
>>>>I'm a bit unclear on one part of your proposal: is the type
>>>>declaration syntax merely a suggestion to the compiler, or does it
>>>>actually affect the semantics of a program?
>>>
>>>The latter, but perhaps not quite the way you're thinking.
>>>(let ((V :: TYPE init)) ...)
>>>has semantics like:
>>>(let ((V (coerce-to-TYPE init))) ...)
>> I dislike this, because it's a hidden semantic in the type
>> declaration.
>
> Huh?  What's hidden about it?  That's the *primary* semantics
> of a non-hidden syntax.

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.

> But if you go along with the basic model that modular arithmetic is
> selected based on the type of the operands, then we need a way
> to convert a normal integer to a modular integer, and back again.
> The coercion model provides that in a convenient way.

Of course we need coercion operators; I'm not objection to the
availability of that.

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.  

Thomas