Version française
Home     About     Download     Resources     Contact us    
Browse thread
Instruction selection in the OCaml compiler: Modules or classes?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris King <colanderman@g...>
Subject: Re: [Caml-list] Instruction selection in the OCaml compiler: Modules or classes?
On 2/22/07, Joel Reymont <joelr1@gmail.com> wrote:
> I'm reading through the icfp99 slides on classes vs modules in OCaml.
> The part that I'm interested in starts on p27 where instruction
> selection in the OCaml compiler is discussed.

I've never seen these slides before; very interesting!  Personally I prefer modules, but find classes useful for the typing tricks you can do with them: the ability to hide type variables via subtyping is one of the prime benefits.  (The comparison in the slides between objects and closures I thought was particularly elucidating, since function closures are the other (clunkier) way of accomplishing the same thing.)

Also of note, the slides talk about late binding being possible with classes but not with modules, but thanks to recursive modules late binding is in fact possible with (some) modules by simply having a "class" module accept a "Self" module as a parameter, whose members are used when late binding is desired.  The final "object" module can then be created by recursively applying the (post-inheritance) "class" module to the "object" module.  The power of Caml's module system continues to amaze me... :)

- Chris