Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Seth J. Fogarty" <sfogarty@gmail.com>
To: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] really HO Functions
Date: Sat, 2 Oct 2004 11:44:46 -0500	[thread overview]
Message-ID: <c7ee6112041002094412f6456d@mail.gmail.com> (raw)
In-Reply-To: <d849ad2a041001233312faa439@mail.gmail.com>

On Sat, 2 Oct 2004 02:33:43 -0400, John Prevost <j.prevost@gmail.com> wrote:
> On Sat, 2 Oct 2004 08:02:52 +0300, Radu Grigore <radugrigore@gmail.com> wrote:
> > I am learning OCaml now. The last two-three days I've written a small
> > prototype; then I have reviewed it and one of the observations was
> > that it contains no second-order function.
> >
> > Possible reasons:
> > 1. higher order functions are hard (intellectually unmanageable)
> > 2. HOFs are not needed in practice above a certain order
> > 3. failure to recognize places where a HOF is needed (beyond the
> > standard examples in tutorial).
> >
> > Number 3 was what prompted me to ask the question: a few examples
> > always help. Unfortunately I didn't yet had time to read the cited
> > articles :(.
> 
> I highly recommend keeping at it and joining the beginners list (if
> you haven't already).  Making and using higher-order (as in 2nd or
> 3rd, at least) functions is one of those things that you start doing
> after you've been using a functional language for a while.  It does
> dramatically simplify your life when you start doing it, but it's not
> immediately obvious how you'll use it.

I've identified two places I've used HOF's, for really rather different reasons.
1) Modularity. This is probably obvious, but the hardest one to do,
and probably the more useful location. I rarely use more than
second-order functions for htis, and it is very often a refactoring.
"Oh look, in this parser we are evaluating, unwrapping ints, and
error-checking in eight places, the only difference is the function we
apply to the integers afterwards. Time for an HOF."

2) Abstraction. These are places I could have hard-coded the functions
I ended up passing in, but didn't so that the algorithm was very
obvious in the code. This allows someone to look at that one chunk of
code and go "alright, so that's the algorithm. How the specifics work
I don't know, but the general overview is independent of the rest of
the code". This may just be me, and is certainly NOT the usual use of
HOFs.

-- 
Seth Fogarty             sfogarty@[gmail.com|rice.edu|livejournal]
Neep-neep at large    AIM: Sorrath
"I know there are people in this world who do not love their fellow
human beings - and I hate people like that" --Tom Lehrer.

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


  reply	other threads:[~2004-10-02 16:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-29 20:48 Jean-Baptiste Rouquier
2004-10-02  5:02 ` Radu Grigore
2004-10-02  6:33   ` John Prevost
2004-10-02 16:44     ` Seth J. Fogarty [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-09-30 17:30 Harrison, John R
2004-09-29 18:48 Radu Grigore
2004-09-29 19:24 ` Jacques Carette
2004-09-29 22:31 ` Jon Harrop
2004-09-29 23:32   ` Marcin 'Qrczak' Kowalczyk
2004-09-30  6:27     ` Diego Olivier Fernandez Pons
2004-09-30 19:27 ` Michal Moskal

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=c7ee6112041002094412f6456d@mail.gmail.com \
    --to=sfogarty@gmail.com \
    --cc=caml-list@inria.fr \
    /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