Version française
Home     About     Download     Resources     Contact us    
Browse thread
[oliver: Re: [Caml-list] Strings as arrays or lists...]
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: William Lovas <wlovas@s...>
Subject: Re: [oliver: Re: [Caml-list] Strings as arrays or lists...]
On Mon, Mar 03, 2003 at 12:10:45PM -0800, brogoff@speakeasy.net wrote:
> On Mon, 3 Mar 2003, Oliver Bandel wrote:
> > What I first have written about the string-stuff,
> > was: It's not FP-like, but I also would be happy
> > with a syntax, that would allow me, to use Array-functions
> > for the Strings.
> 
> That's why I said "Agitate for extensional polyorphism!". You really want a 
> way to overload similar notations. As you must now know, OCaml has no 
> overloading. Extensional polymorphism gives you that overloading, on top of 
> ML, in a way that even people who hate overloading should find fairly 
> nonthreatening. 

You keep skirting around this question by saying that what he really wants
is extensional polymorphism, but overloading is not the only way to get the
same syntax for strings and arrays.  Another way is to have them simply *be
the same thing*.  That is, is there any deep reason not to do

    type string = char array

right up front, and inherit all the Array module's functions?  We could
still keep a String library with all string-specific functions in it, but
we'd gain a unification of many function implementations, and the same
notation for random access to boot.

You mentioned that strings are packed -- meaning that they're more
efficient than generic arrays?  But doesn't O'Caml already have compiler
magic for making float arrays fast and efficient?  Why not just do the same
thing for char arrays?

You indicated towards the end of your email that you feel that strings and
arrays are different enough to warrant different representations, but i'm
not convinced yet.  What's the good reason for separating these two ideas
that are clearly very similar in interface, and probably not too different
in implementation?

William

-------------------
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