English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
RE: [Caml-list] laziness
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-09-06 (06:10)
From: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] laziness
> Doesn't laziness often indicate a bug in the code?  ie.  You've
> written an expression in the program, but that expression is never
> used.  This is dead code, right?  Hence a bug?

Laziness can be useful in some cases (eg : enums in ExtLib) and I use it for
example in a typing algorithm where you need to duplicate big objects type
for unification but you're not sure in advance which field(s) will be
unified, so you delay it when they get accessed. It's kind of internet
browser cache.

Evaluated part of a program can depends on several kind of inputs, and is
undecidable. Then you cannot make automated assertion about what part will
never be evaluated in the general case (although this can be done in
specific cases). However what you can do is automated flow analysis to check
which part of your program are not accessible through some entry points :
this is interesting for dead code removal and test coverage but can be
tricky to do in OCaml.

Nicolas Cannasse

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