[racket] Code Reuse, Object Oriented vs Functional

From: Bardur Arantsson (spam at scientician.net)
Date: Fri Jun 21 15:42:29 EDT 2013

On 06/21/2013 05:23 PM, Ray Racine wrote:
> The Internet is rife with stuff regarding the Expression problem.  Pretty
> much any major language has some posting, paper or article on how it is
> addressed to some degree by the language in question.
> 
> http://en.wikipedia.org/wiki/Expression_problem
> 
> It's a can I have my cake and eat it too issue.
> 
> "add new cases to the datatype and new functions over the datatype, without
> recompiling existing code, and while retaining static type safety"
> 
> You sorta get one and not the other respectively in Functional vs OO.  The
> trick is we all want both damn it.
> 
> FWIW, Scala with its "Type Class" and implicit conversions gets fairly
> close, but its a bit heavy handed.

Just for the record, Scala wasn't the origin of the type class concept
-- it originates in Haskell. (Btw, Scala people tend to refer to it as
"typeclass" to avoid ambiguity with "type" and "class" both of which are
entirely separate concepts in Scala.)

AFAICT both Haskell and Scala's type classes *fully* solve the
expression problem, but maybe I'm missing something... care to enlighten
us what's missing? (as implied by your "gets fairly close")

Regards,


Posted on the users mailing list.