Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Dynamically evaluating OCaml code
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Goerzen <jgoerzen@c...>
Subject: Re: [Caml-list] Dynamically evaluating OCaml code
On Thu, Apr 08, 2004 at 11:20:44AM -0700, Kenneth Knowles wrote:
> On Thu, Apr 08, 2004 at 07:59:04PM +0200, Jean-Marc EBER wrote:
> > I don't need to mention that your previous particular problem is so
> > trivial that it could easily be expressed with arrays as a "one
> > liner" of caml code... Look at Array.sub...
> 
> This is also a general principle - O'Caml is concise enough that a lot
> of helper functions you would expect in imperative scripting languages
> or C are too simple to include, for the sake of cleanliness.  I

That's an excellent practice, one I am still adjusting to.  For
instance, "String.make 1" makes sense as an alternative to
String.string_of_char.

However, while perhaps someone could design a more advanced String.sub
that can count backwards from the end of the string (I posted one such
example) in one line of the code, it may still have merit being in the
library.  Otherwise, everyone will probably end up writing a function
anyway (since it's too ugly to use inline with any frequency) and this
reduces the efficiency of programming with OCaml.

> By the way, list slicing has the same complexity as Array.of_list and
> then Array.sub so it is, in fact, in the standard library.  Don't even
> bother talking about efficiency at a lower level than complexity of
> algorithms until you have a complete, profiled program - and of course
> you are talking about disk access so there's not a chance of the
> slicing being a bottleneck.

My simplified example does not necessary represent all possible ones.
Some people may be dealing with 500MB structures where going back and
forth between lists and arrays is not even an executable option.

-- John

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