From: Alain.Frisch@ens.fr
To: skaller <skaller@users.sourceforge.net>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Reading a large text file
Date: Sat, 1 May 2004 21:51:38 +0200 (MET DST) [thread overview]
Message-ID: <Pine.SOL.4.44.0405012146130.21993-100000@clipper.ens.fr> (raw)
In-Reply-To: <1083439539.20722.93.camel@pelican.wigram>
On 2 May 2004, skaller wrote:
> It can now do slightly better than that. It is possible to use
> the new 'private' keyword to *guard* your mutable list.
>
> module MList = struct
> type 'a mylist = private { head : 'a; mutable tail : 'a mylist option; }
> ..
> let splice a b = ...(* makes a new mylist of a @ b *)
> end
> Here, lists are immutable *publically*.
Not quite.
First, the "private" keyword should be used only in the signature, not the
structure, otherwise the implementation of the module has no special
right. Something like:
module M :
sig type t = private *** end
=
struct type t = *** end
Second, the client cannot create values of the "private" type. This is
not related at all with the mutability of the fields. It can only
deconstruct values (with pattern matching). So you have to expose
constructors explicitly (splice is one of them, but you probably want a
simple Cons).
-- Alain
-------------------
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
next prev parent reply other threads:[~2004-05-01 19:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-28 15:28 André Luiz Moura
2004-04-28 16:28 ` Richard Jones
2004-05-01 14:03 ` Brian Hurt
2004-05-01 15:43 ` Rahul Siddharthan
2004-05-01 16:00 ` [Caml-list] [OcamlDoc] langage support sejourne kevin
2004-05-14 7:15 ` Maxence Guesdon
2004-05-01 18:05 ` [Caml-list] Reading a large text file Richard Jones
2004-05-01 18:25 ` Charles Forsyth
2004-05-01 19:25 ` skaller
2004-05-01 19:51 ` Alain.Frisch [this message]
2004-05-01 20:40 ` skaller
2004-05-01 21:11 ` [Caml-list] Private types skaller
2004-05-01 21:33 ` [Caml-list] Reading a large text file Alain.Frisch
2004-05-17 5:28 ` Eric Stokes
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=Pine.SOL.4.44.0405012146130.21993-100000@clipper.ens.fr \
--to=alain.frisch@ens.fr \
--cc=caml-list@inria.fr \
--cc=skaller@users.sourceforge.net \
/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