caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pierre Weis <pierre.weis@inria.fr>
To: skaller@users.sourceforge.net
Cc: pierre.weis@inria.fr, daniel.buenzli@epfl.ch, caml-list@inria.fr
Subject: Re: lazyness in ocaml (was : [Caml-list] kprintf with user formatters)
Date: Wed, 28 Jul 2004 09:26:21 +0200 (MET DST)	[thread overview]
Message-ID: <200407280726.JAA01775@pauillac.inria.fr> (raw)
In-Reply-To: <1090537249.5870.168.camel@pelican.wigram> from skaller at "Jul 23, 104 09:00:49 am"

[...]
> But this looks very dangerous!

Yes: lazyness in the presence of side-effects is tricky. But don't
worry, that's not the introduction of this new rule that is dangerous,
it is the concept of lazy evaluation and more importantly the mixing
of lazy evaluation and strict evaluation that is difficult in the
presence of side effects.

> Its kind of like reference parameters in C++, which make
> it impossible to tell if  f(expr) can modifiy expr or not
> [without finding which 'f' it is and examining it]

I cannot understand that one. We have that in Caml already and we had
it from the very begining of Caml (1984). For instance, if I write

f (expr)

could you tell me ``if  f(expr) can modifiy expr or not [without
finding which 'f' it is and examining it]'' ?

To the best of my knowledge, the answer is no.

To the best of my knowledge, nobody never complained about that feature.

> > In the lazy case it would destroy an important identity:
> 
> f x <==> let x' = x in f x'
> 
> With your rule, the LHS might not evaluate x, whereas the RHS
> would.

Yes, that's exactly what we want: if (f e) is a lazy application you
don't know if e is evaluated or not. This is just what lazyness is
about !

Also, I didn't know that such an ``important identity'' stands for
Caml expressions. Except in the trivial case where ``x'' just denotes
a variable in the statment. In this case, the statment still holds with
the new rule :)

> Of course we already have that:
> 
> f x y <=/=> let x' = x in y' = y in f x' y'
> 
> since the RHS guarrantees x is evaluated before y,
> whilst it happens by chance in the current Ocaml implementation
> the reverse is true for the LHS.

So what? Is the ``important identity'' wrong after all, being wrong in
this case ? Or do you suggest to suppress currying in order to restore
the ``important identity'' ?

> So even if your rule is sound, it might not be a good idea
> because it breaks 'the substitution principle'.

There is nothing such as your ``substitution principle'' in Caml,
except if we restrict the language to truly trivial expressions (as
soon as expressions may incoporate basic operators such as the integer
addition your ``principle'' does not stand anymore).

> How about sugar:
> 
> \(expr) <==> lazy expr
> 
> Since arguments to be lazily evaluated are never variables,

Wait a minute: do you mean I cannot write f e, if e is just a variable?

If the answer is yes, your suggestion breaks something important (we
still want to apply a function to any expression of the suitable
type); if the answer is no then you would need to write f \x as you
now have to write f (lazy x) with the current compiler. Or you would
have to implement something really strange to handle f e differently
if the expression e is a variable or not.

Best regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


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


  parent reply	other threads:[~2004-07-28  7:26 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-30 16:32 [Caml-list] kprintf with user formatters Damien
2004-07-14 21:10 ` Pierre Weis
2004-07-15  0:17   ` Markus Mottl
2004-07-15  7:30     ` David MENTRE
2004-07-15  7:59       ` Jean-Christophe Filliatre
2004-07-15 23:35         ` henri dubois-ferriere
2004-07-15  7:39     ` Damien
2004-07-15 12:19       ` Markus Mottl
2004-07-15 12:42         ` Basile Starynkevitch [local]
2004-07-15 13:45           ` Markus Mottl
2004-07-15 14:22             ` Basile Starynkevitch [local]
2004-07-15 14:57               ` Markus Mottl
2004-07-16  6:47               ` Pierre Weis
2004-07-16  7:13                 ` Jean-Christophe Filliatre
2004-07-16  7:23                   ` henri dubois-ferriere
2004-07-16  7:44                     ` Jean-Christophe Filliatre
2004-07-16 17:56                   ` Markus Mottl
2004-07-19  9:17                   ` Pierre Weis
2004-07-19  9:32                     ` Jean-Christophe Filliatre
2004-07-16  7:21                 ` henri dubois-ferriere
2004-07-16 17:44                 ` Markus Mottl
2004-07-19 10:10                   ` Pierre Weis
2004-07-19 10:43                     ` Jon Harrop
2004-07-21 15:52                       ` Pierre Weis
2004-07-21 17:43                         ` lazyness in ocaml (was : [Caml-list] kprintf with user formatters) Daniel Bünzli
2004-07-22 16:28                           ` Pierre Weis
2004-07-22 17:03                             ` William Lovas
2004-07-22 23:00                             ` skaller
2004-07-23  3:32                               ` William Lovas
2004-07-28  7:26                               ` Pierre Weis [this message]
2004-07-28  8:06                                 ` skaller
2004-07-28  8:29                                   ` Daniel Bünzli
2004-07-28  9:13                                   ` Pierre Weis
2004-07-28  9:36                                     ` skaller
2004-07-28  9:38                                     ` skaller
2004-07-28 10:17                                 ` Jason Smith
2004-07-28 12:31                                   ` skaller
2004-07-21 20:41                         ` [Caml-list] kprintf with user formatters Jon Harrop
2004-07-22 15:39                           ` Pierre Weis
2004-07-22 22:16                             ` [Caml-list] lazy evaluation: [Was: kprintf with user formatters] skaller
2004-07-22 22:42                             ` [Caml-list] kprintf with user formatters skaller
2004-07-22  8:05                         ` [Caml-list] wait instruction lehalle@miriad
2004-07-22  8:40                           ` Olivier Andrieu
2004-07-22 10:35                             ` lehalle@miriad
2004-07-22 10:33                           ` Vitaly Lugovsky
2004-07-16  6:17             ` [Caml-list] kprintf with user formatters Pierre Weis
2004-07-16 17:14               ` Markus Mottl
2004-07-19 10:00                 ` Pierre Weis
2004-07-16  6:02       ` Pierre Weis
2004-07-16  8:42         ` Damien
2004-07-19  9:00           ` Pierre Weis
2004-07-16 16:52         ` Markus Mottl
2004-07-19  9:28           ` Pierre Weis
2004-07-15 22:20     ` Pierre Weis
2004-07-15 23:01       ` Markus Mottl
2004-07-16 16:17     ` james woodyatt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200407280726.JAA01775@pauillac.inria.fr \
    --to=pierre.weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@epfl.ch \
    --cc=skaller@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).