[bitc-dev] Type Classes for BitC

Swaroop Sridhar swaroop at cs.jhu.edu
Fri Jul 22 13:52:22 EDT 2005


Mark P Jones wrote:
> | Let me give a more serious case.
> | 
> | (define counter
> |     (let (c (mutable 10)) (lambda (x) (begin (set! c (+ c x)) c))))
> | 
> | with the intention that I should get various types (int 16, 
> | 32, 64 etc) 
> | of skip counters.
> | 
> | However, the type of counter is (somewhat) _Num -> _Num and 
> | NOT Num->Num 
> | because of the value restriction. So we will have to define a new 
> | counter for every integer type.

> I'm not sure what you are getting at with this example.  Here are
> some of the things that have me puzzled:
>  
> In short, the example above seems to demonstrate exactly the behavior
> I would both want and expect ...

Actually, all I really wanted to say was, if I have a function:

(define myplus1 +)

myplus1 is as overloaded as +, and we do not have any problem for usages 
like:

(myplus1 10:int16 20:int16)
(myplus1 10:int32 20:int32)

But, if I have a function defined as in:

(define myplus2 (let (x (mutable 0)) +))

this myplus2 is restricted due to the value restriction (as expected), 
and I cannot write:

(myplus2 10:int16 20:int16)
(myplus2 10:int32 20:int32)

So, I wanted to bring up this topic ask whether this is something that 
we should be concerned about in practice, considering heavy use of 
stateful procedures.

But, I thought that Prof. Shapiro will call these myplus-es also funny 
and tried to concoct a counter example which unfortunately became a 
counter-example :-).

Swaroop.


More information about the bitc-dev mailing list