caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: "Marcin 'Qrczak' Kowalczyk" <qrczak@knm.org.pl>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] [Benchmark] NBody
Date: 09 Feb 2005 04:06:46 +1100	[thread overview]
Message-ID: <1107882402.5022.171.camel@pelican.wigram> (raw)
In-Reply-To: <87zmyfjm0a.fsf@qrnik.zagroda>

On Tue, 2005-02-08 at 23:04, Marcin 'Qrczak' Kowalczyk wrote:
> skaller <skaller@users.sourceforge.net> writes:
> 
> > But the types in your record are mutable, and so it can't
> > possibly work.
> 
> It does work: mutable floats are unboxed too (if there are no
> non-float fields).

I'm talking about fully unboxing an array of records of floats
into just an array of floats, and clearly that cannot be
done if the record contains a mutable field, because if you 
assign the record to two different array elements, then
modify the mutable field, both array elements would
have to reflect the assignment.

> > However it isn't clear Ocaml type system uses the most
> > expressive typing of 'constness', i.e. that it propages
> > 'mutable' ness correctly. 
> 
> There is nothing to propagate.

There certainly is for unboxed data structures: if you store
a record with an immutable field into a mutable field,
the immutable field becomes mutable, because you can
always use functional update. The mutability is thus
mutable if the parent is mutable, whether or not 
the field is mutable. In other words mutability is inherited.

In C++ this applies to lvalueness, but constness actually
works in reverse: a non-const field is const if its parent is.

For boxed fields, you may be right there is no propagation
in Ocaml, but perhaps that indicates a lack of expressiveness,
for example record subtyping is missing. In particular
one can believe that a function accepting a record
of immutable fields would not harm a record with the 
same structure but some mutable fields -- roughly
the equivalent of C++ 'const' conversions. However
unless I'm mistaken there is no way to do this,
even though it appears sound and desirable.
So saying 'there is nothing to propagate' isn't
really meaningful, it seems circular: Ocaml doesn't
propagate it therefore there isn't anything to
propagate.

Note I didn't claim there was a bug, I said merely that

> it isn't clear Ocaml type system uses the most
> > expressive typing of 'constness',

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net




  reply	other threads:[~2005-02-08 17:07 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-07 18:57 Christophe TROESTLER
2005-02-07 19:16 ` [Caml-list] " Will M. Farr
2005-02-07 19:36   ` Christophe TROESTLER
2005-02-07 19:55     ` Will M. Farr
2005-02-08 10:34       ` Olivier Andrieu
2005-02-08 10:52         ` Micha
2005-02-07 20:16     ` Markus Mottl
2005-02-07 19:37 ` Martin Jambon
2005-02-07 19:46   ` Christophe TROESTLER
2005-02-07 20:22     ` Martin Jambon
2005-02-07 20:04   ` sejourne_kevin
2005-02-07 20:32     ` Robert Roessler
2005-02-07 22:57     ` Oliver Bandel
2005-02-08  1:29 ` skaller
2005-02-08  1:48   ` Will M. Farr
2005-02-08  9:01     ` Ville-Pertti Keinonen
2005-02-08  9:37     ` skaller
2005-02-08 10:10       ` Ville-Pertti Keinonen
2005-02-08 16:36         ` skaller
2005-02-08 12:04       ` Marcin 'Qrczak' Kowalczyk
2005-02-08 17:06         ` skaller [this message]
2005-02-08 10:25   ` Xavier Leroy
2005-02-08 18:34     ` skaller
2005-02-08 10:43 ` Xavier Leroy
2005-02-08 11:26   ` Ville-Pertti Keinonen
2005-02-08 15:59   ` Florian Hars
2005-02-13 16:40   ` Christoph Bauer
2005-02-13 18:13   ` Christophe TROESTLER
2005-02-24 22:18   ` NBody (one more question) Christophe TROESTLER
2005-02-25 17:06     ` [Caml-list] " John Carr
2005-02-25 17:17       ` Christophe TROESTLER
2005-02-26 16:08         ` John Carr
2005-02-25 17:24     ` Ken Rose
2005-02-25 17:42       ` Oliver Bandel
2005-02-25 17:57     ` Xavier Leroy

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=1107882402.5022.171.camel@pelican.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=qrczak@knm.org.pl \
    /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).