caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Dave Berry" <Dave@kal.com>
To: "Don Syme" <dsyme@microsoft.com>,
	"Pierre Weis" <Pierre.Weis@inria.fr>,
	"Jacques Garrigue" <garrigue@kurims.kyoto-u.ac.jp>
Cc: <caml-list@inria.fr>
Subject: RE: [Caml-list] let mutable (was OCaml Speed for Block Convolutions)
Date: Fri, 15 Jun 2001 17:05:08 +0100	[thread overview]
Message-ID: <8E31D6933A2FE64F8AE3CC1381EEDCE706EF73@NT.kal.com> (raw)

I once advocated a "const" datatype for SML.  The const constructor
would create unique immutable values that could be compared for pointer
equality, satisfying Don's first use of refs.  (It's possible I included
these in the Edinburgh SML Library -- I don't recall after all these
years).  But this idea never caught on.

A similar idea is to define:
  type 'a pointer = 'a option ref
  fun null (ref NONE) = true | null _ = false
  fun ::= (p, v) = p := SOME v

Dave.


-----Original Message-----
From: Don Syme [mailto:dsyme@microsoft.com]
Sent: 15 June 2001 04:20

[ To expand on why "mutable" fields are, IMHO, so much better...  In
Standard ML "refs" get used in data structures for four main purposes: 
  - to get values that can be compared by pointer equality; 
  - to ensure sharing of an allocation cell; 
  - to allow "regular" mutation; 
  - to cope with initializing recursive data structures using "ref
option".  

Because of these multiple uses I honestly used to get "ref" type
constructors nested two or three deep (when designing some
pointer-chasing graph structures)!!  

I was never able to get this code right until I switched to Caml,
precisely because my structures became simpler.  In Caml the combination
of inbuilt pointer equality and "mutable" made things sufficiently
simple, and the ability to allocate at least some recursively linked
objects without using "ref option" also helped.  
]

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


             reply	other threads:[~2001-06-15 16:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-15 16:05 Dave Berry [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-06-15  3:20 Don Syme
2001-06-08 10:23 Dave Berry
2001-06-08  9:00 Dave Berry
2001-06-06 18:35 [Caml-list] OCaml Speed for Block Convolutions William Chesters
2001-06-07 18:20 ` Tom _
2001-06-07 23:49   ` [Caml-list] let mutable (was OCaml Speed for Block Convolutions) Jacques Garrigue
2001-06-08  8:25     ` Ohad Rodeh
2001-06-08 15:21       ` Brian Rogoff
2001-06-08 17:30     ` Pierre Weis
2001-06-08 18:36       ` Stefan Monnier
2001-06-08 19:07         ` Pierre Weis
2001-06-08 19:30       ` Michel Quercia
2001-06-11 13:42         ` Pierre Weis
2001-06-12  3:21           ` Jacques Garrigue
2001-06-12  7:43             ` Pierre Weis
2001-06-12  8:31               ` Jacques Garrigue
2001-06-12 13:15                 ` Georges Brun-Cottan
2001-06-12 21:54               ` John Max Skaller
2001-06-15  9:55       ` Michael Sperber [Mr. Preprocessor]

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=8E31D6933A2FE64F8AE3CC1381EEDCE706EF73@NT.kal.com \
    --to=dave@kal.com \
    --cc=Pierre.Weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=dsyme@microsoft.com \
    --cc=garrigue@kurims.kyoto-u.ac.jp \
    /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).