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: Issac Trotts <ijtrotts@u...>
Subject: Re: [oliver: Re: [Caml-list] Strings as arrays or lists...]
William Lovas wrote:

>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?
>
Char arrays take up four times as much space as strings, but there is a 
tradeoff
of space versus time.  The statement

  let a = Array.make 2000000 ' ';;

takes no noticable time, but
 
  let s = String.make 2000000 ' ';;

takes about 7 seconds to run on my computer.

Issac Trotts

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



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