Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: [Caml-list] productivity improvement
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Rogoff <bpr@a...>
Subject: Re: [Caml-list] productivity improvement
William Lovas writes:
> It strikes me that although you were able to quite easily translate this
> toy evaluator example into C++, this may not have been the case with a
> larger, more complex example. 

Even this toy example was not really translated into C++. Translating OCaml 
functions, which can be closures, to C style function pointers, is a cheat. 
To be accurate, you need to model these as C++ functors (yes, I hate that 
terminology but that's what Stroustrup uses) to simulate closures. This is 
inevitably a pain, because simulating nested functions in a lexically
scoped language means that the object constructor has to have the variables 
that the "execute" function uses explicitly passed in. 

> It's something that scales exponentially, so you're probably not going to 
> find very many small, concise examples that show conclusively how much 
> easier O'Caml is. 

Actually, I think that there are quite a few.

Anyways, if you're interested in pursuing the extensibility question raised
here further, Jacques Garrigue wrote a nice little paper comparing sum types,
polymorphic variants, and classes on a simple evaluator example.

-- Brian
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: