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

Re: the forward method [dynamic vs. static typing]




On Dec 9, 2003, at 6:16 PM, Chris Page wrote:

> On Dec 9, 2003, at 16:40, Ken Shan wrote:
>
>> Static typing can make programs more concise: I can write
>>
>>     getLine >>= print . (/2) . read
>>
>> or
>>
>>     getLine >>= print . not . read
>
> I don't see what this has to do with static or dynamic typing. It has 
> more to do with whether or not your language allows for some type of 
> polymorphism so you can use the same function/message name, which is 
> an orthogonal concern. Dylan, Lisp, Smalltalk and C++ all allow for 
> this.

Except that the implementation of "read" here looks like it's being 
chosen based on the expected *return* type, not based on the arguments, 
and the return type is being inferred from subsequent operations.  
That's pretty cool, although as someone that mostly uses 
message-passing languages, I have to confess that it makes me a little 
uneasy, as does any kind of "static dispatch" (eg, Java/C++ style 
method overloading).

For example, wouldn't this mean that simply loading an implementation 
of "not" that operated on, say, numbers, would change the semantics of 
this program?  I'm not used to having far reaching changes come from 
increasing the domain of a function, but maybe it's not a big deal in 
practice.

Anyway, this was an eye-opening example, thanks.  Is assume it's real 
Haskell?

Avi