Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Pierre Weis <Pierre.Weis@inria.fr>
To: taha@cs.chalmers.se (Walid Taha)
Cc: caml-list@inria.fr
Subject: Re: Imperative programming in Caml
Date: Tue, 8 Aug 2000 23:10:08 +0200 (MET DST)	[thread overview]
Message-ID: <200008082110.XAA20025@pauillac.inria.fr> (raw)
In-Reply-To: <Pine.SOL.4.21.0008082026110.562-100000@muppet70.cs.chalmers.se> from Walid Taha at "Aug 8, 100 08:30:19 pm"

Hi Walid

> > If you write:
> > 
> > imperative call;
> > let x = blah in
> >   imperative call
> > 
> > then you get a little distracted by the indentation.  
> 
> Got it!
> 
> > Mmm.  I don't think you're going to have much success at showing that
> > O'Caml is a reasonable language without using at least some
> > polymorphism.  Perhaps this restatement of my previous code would
> > help, though:
> > 
> > type optional_int =
> >        | No_Int
> >        | Some_Int of int
> 
> I feel you were "righter" the first time.  An "option" type is somehow
> semanticaly implict in having "null/nill" in every pointer.  So, I think
> it is reasonable to interpreter "'a pointer" as "'a option ref".  This
> also suggests a naturally way to translate imperative programs to
> functional programs systematically.
> 
> Thanks again for the great feedback.
> 
> Walid.

Your problem seems to have something to do with elementary programming
in Caml; you may have a look at the documentation, in particular the
FAQ where basic indentation hints are given in the programming guide
lines (http://pauillac.inria.fr/caml/FAQ/pgl-eng.html), and questions
about imperative programming in Caml including the existence of
imperative pointers and their encoding in Caml are discussed in
details (http://pauillac.inria.fr/caml/FAQ/pointers-eng.html).

Note: if you really do not want to use any kind of polymorphism, I'm
afraid you will have a bad time to write and explain imperative
programming examples in Caml, since you cannot use references ('a
ref), nor arrays ('a array), nor options ('a option), nor lists ('a
list); if you also consistently banish polymorphism from your function
type schemes, what could you do without the basic predicates such that
(=) (that has type 'a -> 'a -> bool), or even any comparison
predicates (<, <=, <>, ...)  that are also polymorphic ?

Hope this helps,

Pierre Weis

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




  reply	other threads:[~2000-08-08 21:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-25 21:47 overhead of GC in caml runtime? Norman Ramsey
2000-07-28  9:52 ` Xavier Leroy
2000-08-03 19:20   ` Imperative programming in Caml Walid Taha
2000-08-04 19:43     ` Markus Mottl
2000-08-04 19:57       ` Walid Taha
2000-08-06  1:59         ` John Prevost
2000-08-08 18:01           ` Walid Taha
2000-08-08 18:23             ` John Prevost
2000-08-08 18:30               ` Walid Taha
2000-08-08 21:10                 ` Pierre Weis [this message]
2000-08-09 13:50                   ` Walid Taha
2000-08-04 18:33 Don Syme
2000-08-04 19:48 ` Walid Taha

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=200008082110.XAA20025@pauillac.inria.fr \
    --to=pierre.weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=taha@cs.chalmers.se \
    /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