James Long | 17 May 15:05

full polymorphism in Pre-Scheme

Hi,

I have a few questions about Pre-Scheme's type system.  I will be  
referencing the following paper as "the paper":

Pre-Scheme: A Scheme Dialect for Systems Programming (http://citeseer.ist.psu.edu/196055.html 
)

and I am using Pre-Scheme from scheme48 v1.8.  Note that I don't have  
much experience with type systems, this is just my first step in  
understanding them.  I am interested in these problems because I would  
like to extend Pre-Scheme's type system to treat numbers with more  
granular interest, such as integer16 and integer32.

------

1.The paper states that Pre-Scheme's type reconstruction algorithm  
supports 4 kinds of polymorphism, one of them being full  
polymorphism.  The example case in the paper to illustrate this is one  
which would normally be rejected by basic type systems:

(define (add-one x)
   (+ x 1))

(* (add-one 1.5)
     (vector-ref v (add-one 3)))

I understand the polymorphic nature of the above expressions, and how  
full polymorphism would support this.  The problem is that Pre-Scheme  
does *not* seem to support this, from pragmatic testing.  The  
peculiarity of it stems from the set of functions [+ - * / ...] being  
explicitly of type (=> (INTEGER ...) INTEGER), forcing the existence  
of the set of functions [fl+ fl- fl* fl/ ...] for floats.  Wouldn't  
full polymorphism allow for just one set of mathematical functions?   
What is the disconnect between C-like overloading and full polymorphism?

2. The paper also describes coercions:

"Coercions are limited to those that are computationally inexpensive,  
for example between different numeric types."

I can't seem to glean this anywhere in the current Pre-Scheme.  And  
example would be the set of integer functions referenced above.  My  
interpretation of the above statement is that I should be able to call  
(+ 1.0 1.0) and get 2 as a result (the floats are coerced to integers).

--------

-James


Gmane