caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Don Syme <dsyme@microsoft.com>
To: "'Pierre Weis'" <Pierre.Weis@inria.fr>, whitley@cse.buffalo.edu
Cc: caml-list@inria.fr
Subject: RE: Functional composition operator?
Date: Tue, 8 Dec 1998 12:09:49 -0800	[thread overview]
Message-ID: <39ADCF833E74D111A2D700805F1951EF0B2EF6A8@RED-MSG-06> (raw)

> 
>  -- it only save a few characters in programs
>      (Compare
>       let h = f o g 
>       with
>       let h x = f (g x);;)

As you say, you can always define the infix identifier, so there's no
hassle, i.e. I'm not complaining.  However, the comparison should be
    f1 << f2 << f3 << f4 
v.
    (fun x -> f1(f2(f3(f4 x))))

because we may not be binding the on-the-fly value to a name.  Saving
parentheses is clearly a good idea - most the ML syntax is directed to this.
Even worse consider

    f1 << f2 x y z << f3 << f4 a b

v.
   (let f4' = f4 a b in
    let f2' = f2 x y z in
    (fun x -> f1(f2' z(f3(f4' x)))))

since in the latter case we may be taking advantage of the partial
evaluation of the closures to, for example, precompute some tables based on
the information in x,y,z and a,b.  I know which I prefer!

In 16,000 lines implementing the interactive theorem prover DECLARE there
are 220 uses of composition, so one every 70 lines or so.  There are 500
uses of "map", so it's relatively common in that one random example at
least.

Cheers,
Don

------------------------------------------------------------------------
At the lab:                                     At home:
Microsoft Research Cambridge                    11 John St
St George House                                 CB1 1DT
Cambridge, CB2 3NH, UK
Ph: +44 (0) 1223 744797                         Ph: +44 (0) 1223 722244
http://research.microsoft.com/users/dsyme
email: dsyme@microsoft.com
   "You've been chosen as an extra in the movie
        adaptation of the sequel to your life"  -- Pavement, Shady Lane
------------------------------------------------------------------------





             reply	other threads:[~1998-12-09  9:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-08 20:09 Don Syme [this message]
  -- strict thread matches above, loose matches on Subject: below --
1998-12-09 12:00 Don Syme
1998-12-08 19:51 Don Syme
1998-12-08 18:08 Andrew Kay
1998-12-08 20:32 ` John Prevost
1998-12-09 16:17 ` Anton Moscal
1998-12-08  5:23 John Whitley
1998-12-08 17:02 ` Pierre Weis
1998-12-08 21:52   ` John Harrison
1998-12-09 10:58     ` Pierre Weis
1998-12-09 17:17       ` John Harrison
1998-12-11 13:57         ` Pierre Weis

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=39ADCF833E74D111A2D700805F1951EF0B2EF6A8@RED-MSG-06 \
    --to=dsyme@microsoft.com \
    --cc=Pierre.Weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=whitley@cse.buffalo.edu \
    /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).