Re: Sys.time( ) and Unix.gettimeofday( ) ;;

"'Mr. Herr' [email protected] [ocaml_beginners]" <[email protected]> Mon, 7 Mar 2016 19:10:26 +0100
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <[email protected]>
On 07.03.2016 18:40, Douglas Lewit [email protected] [ocaml_beginners] wrote:
> > > First off, EXACTLY WHAT IS TAIL RECURSION.  I'm assuming that any > recursive
function that uses an "accumulator" is tail-recursive, but > that seems like a pretty
poor definition of tail-recursion.  So > exactly what is the key difference between
normal recursion ( or > forward recursion ) and tail-recursion?  Is it true that >
tail-recursion is always faster and more efficient than forward > recursion?  Are
there any notable exceptions to that rule? > >
*a lot* has been said and written about tail recursion, see for example
https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_1.2.1
where the author calls tail recursion  an "iterative process".

It is a simple as this: when the recursive call is made, no local variable is active
or needed,
the new state in the evaluation or computation process is completely recorded in
the function parameters. In this case a compiler can optimize a recursive call
to a simple loop.


> > Also, how on earth do I tell Ocaml to ignore Warning 26?  I mean.... > I know I
don't need the "myList" variable per se, but I had to create > it for the sake of
scoping, right?  So how can I tell the > interpreter/compiler "Hey, it's okay.  I'm
just creating a dummy > variable and I plan to just throw it away.  I'm not going to
really > use it".  What would happen if I used ocamlopt or ocamlc on such a >
function?  Would it compile?  Would I still see the error message? > Would the
program execute in spite of that error message?
Why don't you just try it? Compiling to byte code or native code is soo easy.

I would do any benchmarking with compiled code anyway.

/Str.