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
[Caml-list] kprintf with user formatters
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-07-21 (20:44)
From: Jon Harrop <postmaster@j...>
Subject: Re: [Caml-list] kprintf with user formatters
On Wednesday 21 July 2004 16:52, Pierre Weis wrote:
> Yes this remark is completely relevant:

I knew it. ;-)

> the built-in && and || 
> operators and the if then else construct (considered as a 3 places
> operator) are the only lazy constructs of the language.

Is "match pred with true -> expr1 | false -> expr2" not equivalent to "if pred 
then expr1 else expr2"? If so, isn't pattern matching a fourth lazy 

Just after I wrote that last post I realised that this approach could actually 
be useful in numerical contexts. As a trivial example, integer multiply could 
lazily evaluate its second argument (only when it is pure, if conventional 
semantics are to be preserved), not needing it if the first argument is zero. 
This may be useful in more complicated settings, i.e. when dealing with data 
structures rather than primitive types and when predicates over the data 
structure can be evaluated much more quickly than the corresponding 

Such functionality can, of course, be implemented in vanilla OCaml. But I'd 
like to see a language which allowed mathematics to be expressed in a 
notation as close to conventional written form as possible (although I prefer 
type distinctions, like "+" vs "+.") whilst retaining efficiency (I'd also 
like to see deforesting, e.g. in vector expressions without having to resort 
to maps, folds etc.).

Perhaps an OCaml -> OCaml optimising compiler would be a good project for 
someone? That way implementation details and their benefits can be examined 
without having to touch the OCaml compilers. I think it could be quite fun to 
play with such a thing...


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