Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Ask for a more efficient way to deallocate memory	(full version)
Date: Sun,  9 Dec 2007 23:34:51 +0100	[thread overview]
Message-ID: <1197239691.475c6d8b14f0b@webmail.in-berlin.de> (raw)
In-Reply-To: <200712092212.30563.jon@ffconsultancy.com>

Zitat von Jon Harrop <jon@ffconsultancy.com>:

> On Sunday 09 December 2007 21:39, Fabrice.Pardo@lpn.cnrs.fr wrote:
> > Hello, and sorry for my previous unfinished message.
> >
> > As the function Unix.opendir returns a value,
> > we can expect that Unix.closedir will be automatically
> > called when the dir_handle value is no more referenced.
>
> You cannot expect that.
>
> > ...
> > My question is how to write a code as efficient
> > as it would be possible using a reference-counted language.
>
> RAII wrapped in a higher-order function as Olivier described is the
> idiomatic
> solution in OCaml.

1st: it has a little bug ;-)
2nd: why using a higher-level function here?

I would directly code the reading of the dir,
because the typical application of opendir would
be to read the contents of the dir.

But possibly you have some more ideas on how to use
the contents of a dir, different than reading ot's contents? ;-)

Or perhaps it's a matter of taste, what one preferes.

Higher-order functions are a fine thing;
I would use them, if necessary, but not
obessively every time and everywhere.

Ciao,
   Oliver

P.S.: One possibly also could use CPS for that open-read-close stuff.
      But I'm not sure if this would make sense.


  reply	other threads:[~2007-12-09 22:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-09 21:39 Fabrice.Pardo
2007-12-09 21:55 ` [Caml-list] " Olivier Andrieu
2007-12-10 11:25   ` Fabrice Pardo
2007-12-10 12:03     ` Michaël Le Barbier
2007-12-10 16:33     ` Oliver Bandel
2007-12-10 20:27       ` Richard Jones
2007-12-10 21:05         ` Oliver Bandel
2007-12-10 21:15         ` Gordon Henriksen
2007-12-10 22:13           ` Oliver Bandel
2007-12-10 22:59             ` Jon Harrop
2007-12-10 23:29               ` Jon Harrop
2007-12-11  2:03               ` Yitzhak Mandelbaum
2007-12-15 21:33               ` Oliver Bandel
2007-12-16 15:14                 ` Jon Harrop
2007-12-10 23:24           ` Jon Harrop
2007-12-09 21:57 ` Oliver Bandel
2007-12-09 22:12 ` Jon Harrop
2007-12-09 22:34   ` Oliver Bandel [this message]
2007-12-09 22:16 ` Oliver Bandel

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=1197239691.475c6d8b14f0b@webmail.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@yquem.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