caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>,
	 Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: OCaML List Mailing <caml-list@inria.fr>
Subject: Re: [Caml-list] Feedback on -safe-string migration attempts
Date: Mon, 06 Oct 2014 10:15:06 +0200	[thread overview]
Message-ID: <54324F8A.4070004@frisch.fr> (raw)
In-Reply-To: <8BB0EB51-3516-4CB9-94EC-513BA87CD4FF@math.nagoya-u.ac.jp>

On 10/06/2014 04:11 AM, Jacques Garrigue wrote:
> Actually, I think no decision was reached whether the ability to have
> different internal representations for string and bytes is really important.
> This may matter when you use javascript as backend, but otherwise?

I think it's good to keep the freedom to change the representation of 
immutable text.  This could simplify some migration path towards Unicode 
and/or allow using more clever representations (such as ropes, strings 
with lazy concatenation, etc).

Generally speaking, I agree with Gabriel that the distinction between 
strings and bytes is more about "text" vs "compact byte array" data, 
than between immutable vs mutable.  I'm not sure about the need to track 
immutability (or read-only permission) on "byte array", though.  Why 
would this be more important than on other kind of arrays?   In 
particular, for numerical code, it would be equally useful to specify 
immutability of vectors/matrices.  Do we want to go into this direction 
of tracking mutation of arrays?

Actually, I think it would be interesting to introduce a module type 
"ARRAY" for arrays with a fixed type "elt" of elements, add a Make 
functor to the Array module, and arrange so that "Bytes" is a subtype of 
"ARRAY with type elt = char" (in particular, it's "t" type shouldn't be 
more parametric than the one in the ARRAY signature).  We could 
similarly provide a compact "BoolArray" implementation, and if we ever 
decide to drop the automatic runtime unboxing of float arrays, we would 
of course provide a "FloatArray" replacement. "Polymorphic" algorithms 
on arrays could be parametrized by a first-class ARRAY module argument 
(and this would possibly work nicely with modular implicits, and 
possibly with a more aggressive inliner).

This is quite independent from the current discussion, but perhaps it 
shows that we shouldn't treat "Bytes" too specifically compared to other 
kinds of arrays.


Alain

  reply	other threads:[~2014-10-06  8:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-05 17:19 Gabriel Scherer
2014-10-06  2:11 ` Jacques Garrigue
2014-10-06  8:15   ` Alain Frisch [this message]
2014-10-06 11:08   ` Gabriel Scherer
2014-10-06 10:03 ` Gerd Stolpmann

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=54324F8A.4070004@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    --cc=garrigue@math.nagoya-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).