[bitc-dev] constraining bitc's type system
Swaroop Sridhar
swaroop.sridhar at gmail.com
Fri Sep 15 19:09:16 CDT 2006
Sam Mason wrote:
> Maybe I just like the low level control and the extra memory to store
> all these versions and a bit more cache pressure to get them back
> seems import. How much this matters in reality I don't know though.
>
> I'm only suggesting that the specific members that you want to use
> polymorphically need to be boxed and if you're not writing completely
> generic code not even that restriction need apply. It's at this point
> I realise that it wouldn't be polymorphism any more. Humm. I still
> think it would be nice to be able to know that specific patterns wouldn't
> result in polyinstantiation and so would have more predictable runtime
> behaviour and the bonus of being able to interface with external code
> without too much work.
Actually, I think it is not difficult to get what you want even in the
existing system. Prof. Shapiro had suggested a while ago that we should
have a special typeclass (say refType) to which all reference types
belong (that is, the compiler will automatically add relevant
instances). Now, you can write:
(define (f x:(forall ((refType 'a)) 'a) x)
This will ensure that the polymorphism is constrained to ref-types only,
and you can be sure that there will be no polyinstantiation due to the
polymorphism of 'a.
Swaroop.
More information about the bitc-dev
mailing list