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

Re: FP+OO



Shriram Krishnamurthi [mailto:sk@cs.brown.edu] wrote:
> Example: people who say "OO is about data abstraction".  And what is ML 
> about?  Plucking chickens?

Not really a technical comment, but rather a personal one:

When I read ML code, the thing that makes it look like ML to me is seeing 
functions defined inductively with pattern matching. This can make code a
marvel 
of clarity; for example, ML (and Haskell) is the only language in which I
can 
read and understand the code for balancing a red-black tree. (In other
languages 
I take the diagram from CLR and manually compile the picture into the
language.)

However, when I start writing code that makes really extensive use of ML's 
data abstraction facilities (eg, its tres cool module system), then I can't
use
pattern-matching, because you can only write patterns with the concrete data

constructors. 

So (to my eyes at least) very abstractly written ML code stops looking like 
ML. 

This is one of the reasons I'm so interested in multimethods, because they
seem to offer an avenue for writing code that looks like pattern matching
but operates on types. Likewise but differently with keyword arguments on 
functions.

--
Neel Krishnaswami
neelk@cswcasa.com