Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 
construct?

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 
expression.

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...

Cheers,
Jon.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners