caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Re: exception safety / RAII ?
Date: Tue, 8 Mar 2005 22:56:21 +0100	[thread overview]
Message-ID: <20050308215621.GD1877@first.in-berlin.de> (raw)
In-Reply-To: <200503071710.52544.jon@jdh30.plus.com>

On Mon, Mar 07, 2005 at 05:10:52PM +0000, Jon Harrop wrote:
> On Monday 07 March 2005 14:37, Stefan Monnier wrote:
> > > I very rarely have problems with this.
> >
> > Very rarely having problems with something can't save it from being
> > a very bad practice.  Not explicitly closing your files is (in 99% of the
> > cases) just sloppy coding.
> 
> If we're talking about programs which are expected to run for an arbitrary 
> amount of time (servers, the top-level etc.) then yes.
> 
> However, many programs run for a short time and, in these cases, I believe 
> that OCaml guarantees to close your files at least upon program termination, 
> if not before. Therefore, I would say that implicitly deallocating external 
> resources is not sloppy coding in general.
> 
> > Kinda like letting a GC finalizer close 
> > your windows: when the effect is visible from outside the process it
> > shouldn't be done in a finalizer.
> 
> The term "visible" in this context is subjective.
[...]

If we say "visible from an outer environment", then it is clear,
that this is really unfunctional programming style.

What you are suggesting here?
... => It's how to write programs that introduce side-effects in a statistical
manner and hoping on some subjective likeliehoods that all works well
for all the time.

So, why are you using and promoting functional programming style
(which yields to more safeness in programs), when on the other
side you are layzy in programming?

That is, where the difference is between lazy evaluation of a
programming language and lazy programmer's habbits!

Some people rely on Perl's reference counting and are happy without
"use strict", and others rely on OCaml's Garbage Collector and
are happy with "-unsafe"-option....


But be sure: to write good and reliable software means to rely
on *nothing*!

You can write crap software in *every* language, if you want to...

...and crap begins, where the programmer is to lazy to write
good code.

Good code menas: good readable/understandable/good documented,
  but also reliable because of "knowing what's going on",
which means: prefer functional style, not imperative (and the reason is:
imperative code has side-effects you can not always oversee and which yields
to *stochastical* behaviour ---> that's the same problem, what you
are introducing, when relying on the Garbage Collector instead
of writing good code!).

The advantages of FP will be diminished by your style of programming!


It's like

let const = ref 1 (* no likeliehood here *)
let baviour_of_your_program = ..... (* something wired*)

  let _ = Random.self_init ();
          
    baviour_of_your_program  const (Random.float 10000.0)

Ciao,
   Oliver


P.S.: I tried Random.float max_float and it seems to be always between
       1.<something> * 10^307 ...  1.<something> * 10^308
      Is this a problem of initialization, or a problem of the Random-algorithm,
      or a kind of strange (?) behaviour of a random walk?


  parent reply	other threads:[~2005-03-09  7:29 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-05 18:16 Michael Benfield
2005-03-05 18:44 ` [Caml-list] " Gerd Stolpmann
2005-03-07  0:03 ` Jon Harrop
2005-03-07  1:32   ` Stefan Monnier
2005-03-07  2:48     ` [Caml-list] " Brian Hurt
2005-03-07 13:30     ` Jon Harrop
2005-03-07 14:37       ` Stefan Monnier
2005-03-07 17:10         ` [Caml-list] " Jon Harrop
2005-03-08 13:07           ` Damien Doligez
2005-03-08 21:56           ` Oliver Bandel [this message]
2005-03-09 13:34             ` Damien Doligez
2005-03-09 14:48           ` Stefan Monnier
2005-03-09 16:19             ` [Caml-list] " Jon Harrop
2005-03-09 22:45               ` [Caml-list] Re: exception safety / RAII Oliver Bandel
2005-03-09 23:42                 ` Charles Forsyth
2005-03-10 14:33               ` exception safety / RAII ? Stefan Monnier
2005-03-10 16:52                 ` [Caml-list] " Jon Harrop
2005-03-11 14:46                   ` Michael Walter
2005-03-12 22:54                   ` Stefan Monnier
2005-03-07 15:21       ` [Caml-list] " Michael Walter
     [not found]         ` <200503071729.20117.jon@jdh30.plus.com>
2005-03-07 18:47           ` Michael Walter
2005-03-08  1:10             ` Jon Harrop
2005-03-08 22:19               ` Oliver Bandel
2005-03-08 22:53               ` Daniel Yokomizo
2005-03-09  1:21                 ` [Caml-list] " Jon Harrop
2005-03-09 13:21                 ` Damien Doligez
2005-03-08 11:33             ` [Caml-list] " Ville-Pertti Keinonen
2005-03-08 12:32               ` Richard Jones
2005-03-08 14:17                 ` Michael Walter
2005-03-08 18:28               ` Jon Harrop
2005-03-08 21:34                 ` Damien Doligez
2005-03-09 15:05                 ` Stefan Monnier
2005-03-09 22:30                   ` [Caml-list] " Marcin 'Qrczak' Kowalczyk
2005-03-10 14:20                     ` Stefan Monnier
2005-03-08 21:32       ` [Caml-list] " Oliver Bandel
2005-03-07  3:31   ` [Caml-list] " Michael Walter

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=20050308215621.GD1877@first.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;
as well as URLs for NNTP newsgroup(s).