From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id EEAE27FA01 for ; Sat, 5 Jul 2014 13:24:25 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.126.131; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.126.131; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.kundenserver.de) identity=helo; client-ip=212.227.126.131; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@mout.kundenserver.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AigBAKjft1PU436DlGdsb2JhbABag2CvE5dwAYEGFg8BAQEBBwsLCRIqhAMBAQQBJy4ZCwULCxgNISEkEgYTCQkJiBMDCQwJw1YDCoZSF4lJgzEKgXgmB4RDBYRpBYtziBUDg0WFQgWGaYlZag X-IPAS-Result: AigBAKjft1PU436DlGdsb2JhbABag2CvE5dwAYEGFg8BAQEBBwsLCRIqhAMBAQQBJy4ZCwULCxgNISEkEgYTCQkJiBMDCQwJw1YDCoZSF4lJgzEKgXgmB4RDBYRpBYtziBUDg0WFQgWGaYlZag X-IronPort-AV: E=Sophos;i="5.01,607,1400018400"; d="asc'?scan'208";a="70241014" Received: from mout.kundenserver.de ([212.227.126.131]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 05 Jul 2014 13:24:25 +0200 Received: from office1.lan.sumadev.de (dslb-188-107-170-128.pools.arcor-ip.net [188.107.170.128]) by mrelayeu.kundenserver.de (node=mreue004) with ESMTP (Nemesis) id 0Lb6lR-1WN9Z81J1d-00kgEI; Sat, 05 Jul 2014 13:24:23 +0200 Received: from [192.168.0.146] (546BEFE6.cm-12-4d.dynamic.ziggo.nl [84.107.239.230]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id A5588DC270; Sat, 5 Jul 2014 13:24:22 +0200 (CEST) Message-ID: <1404559455.4384.32.camel@e130> From: Gerd Stolpmann To: Markus Mottl Cc: caml-list Date: Sat, 05 Jul 2014 13:24:15 +0200 In-Reply-To: References: <1404501528.4384.4.camel@e130> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-0u8yp0onPSwqHJRGXSMf" X-Mailer: Evolution 3.10.4-0ubuntu1 Mime-Version: 1.0 X-Provags-ID: V02:K0:5n7KafSOJM+dBjOv/XYwF2rWKOmuYm1GPc8pjeh3sGu RBFWMmBWNSgRON+4t+/FWAEnD0PGWH9pvXBDL+E10UyRcO5mTT nrkb9SO91If3m8TnWZD+zT8xKJaOutzXvZNLJFyNipVKA2J4S6 7Cdg7o//6r0QuHKfQoOcAxFZ309EB9h52HB6AMnrLL0mLXONMT fFzZ0bp1b8tVkBwiz62Iqnp0Ek62XTTkYOA66cA3e4t1BZOhbP CQPsRUiY4MBo8WKm/AhHwgG3Uj/kJ8k4kbyIEdB4G8qHv6hd0a TJVb3P/RpfzUfcTaLhfaRFCPsofAOwmzNZqrQqirUafwohMa2t BoqgQsqsavvRPgRshsIqKuovjZX1v0HieE0bqdFby Subject: Re: [Caml-list] Immutable strings --=-0u8yp0onPSwqHJRGXSMf Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable Am Freitag, den 04.07.2014, 17:01 -0400 schrieb Markus Mottl: > I agree that the new concept has some noteworthy downsides as > demonstrated in the Lexing-example. Your proposed solution 2 > (stringlike) would probably solve these issues from a safety point of > view. The downside is that the complexity of string-handling would > increase even more, because then we would have three types to deal > with. I personally prefer safety over convenience, but other people's > (especially beginner's) mileage may vary. Well, the complexity can be reduced a bit by using phantom types: type string =3D [`String] stringlike type bytes =3D [`Bytes] stringlike and then just define function-by-function what is permitted: val get : 'a stringlike -> int -> char val set : [`Bytes] stringlike -> int -> char -> unit val sub : 'a stringlike -> int -> int -> [`String] stringlike val sub_bytes : 'a stringlike -> int -> int -> [`Bytes] stringlike etc., and the modules String and Bytes would just contain aliases of these functions with monomorphed typing. I don't know, though, whether we can be safe to never see the polymorphic typing when just using string and bytes. It would be a bit surprising for beginners to see that, and you sometimes would have to deal with unresolved type variables. > The Bigarray-approach doesn't seem appealing to me. Strings are much > more lightweight, since they can be allocated cheaply on the > OCaml-heap. E.g. String.create is about 10x-100x faster than > Bigarray.create. That seems too big to ignore. Oh, we ignore already that Unix.read and Unix.write copy all data through an additional buffer because we cannot pass an OCaml string directly to the OS while another thread could relocate this string. So that copy would be eliminated. So I'd guess you are normally even faster with bigarrays, at least when you only look at the use as I/O buffers. But there might be other uses where this is different. Gerd >=20 > Regards, > Markus >=20 > On Fri, Jul 4, 2014 at 3:18 PM, Gerd Stolpmann w= rote: > > Hi list, > > > > I've just posted a blog article where I criticize the new concept of > > immutable strings that will be available in OCaml 4.02 (as option): > > > > http://blog.camlcity.org/blog/bytes1.html > > > > In short my point is that it the new concept is not far reaching enough, > > and will even have negative impact on the code quality when it is not > > improved. I also present three ideas how to improve it. > > > > Gerd > > -- > > ------------------------------------------------------------ > > Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de > > My OCaml site: http://www.camlcity.org > > Contact details: http://www.camlcity.org/contact.html > > Company homepage: http://www.gerd-stolpmann.de > > ------------------------------------------------------------ > > > > > > > > -- > > Caml-list mailing list. Subscription management and archives: > > https://sympa.inria.fr/sympa/arc/caml-list > > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > > Bug reports: http://caml.inria.fr/bin/caml-bugs >=20 >=20 >=20 > --=20 > Markus Mottl http://www.ocaml.info markus.mottl@gmail.com >=20 --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------ --=-0u8yp0onPSwqHJRGXSMf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJTt+BfAAoJEAaM4b9ZLB5T9SEH/AqRHjLBMeTf38+OkVFEn5YU QQ04R/JmY6ntx+WHanQaK2ztYvDVCAO1AnaihdIwa014CXsEsD11jtRDarOQPVhG KI9tylB9Fevy+TiHx5umeoIHhrU9/qNFC+vzmJ3UA2+3U+BvuJeC6FXNGnkN+mjV //hiID6Qrol3U/rqNKv/0LybJi1PqgH50rLr8ofdzeSHCks7eQeUnnGk2Dbxh3iI mw9fDB0jiS86gG1gtO21h/nHmc1hZRsLZfXb8IEdkyVvS7ohBP6lO8k4yf8VHEx4 w1oaV1NbSyLnfs3iz3Uhr97dSdY8XhcRh0LW0Qcgbl+6tlDb3/c8uVa+nq4aasA= =11Pw -----END PGP SIGNATURE----- --=-0u8yp0onPSwqHJRGXSMf--