Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Warren Harris <wh232@pacbell.net>
To: "Ram Bhamidipaty - ramb@sonic.net"
	<+caml+warren+a62ff5af68.ramb#sonic.net@spamgourmet.com>
Cc: caml-list@pauillac.inria.fr
Subject: Re: [Caml-list] beginner question about tail recursion (caml: addressed to trusted sender for this address)
Date: Sun, 31 Aug 2003 03:06:19 -0700	[thread overview]
Message-ID: <3F51C89B.1070802@pacbell.net> (raw)
In-Reply-To: <m33cfihi7f.fsf@oak.ramandgita.com>

Unless you're dealing with very long lists, or very deep data structures 
(or writing library code that might be used with long lists, etc), going 
to extra work to avoid tail recursion isn't worth it. Being properly 
tail recursive allows the compiler to make an optimization that keeps 
the stack from growing for each recursive call. Usually you can recurse 
quite a few times (thousands) before overflowing your stack is ever an 
issue in practice. I'm not saying that being properly tail recursive 
isn't important, but it's usually not the first thing you need to worry 
about when learning a new language.

Warren

Ram Bhamidipaty - ramb@sonic.net wrote:

>Hi I am just getting started with OCaml. My understanding is
>that it is desirable to write function in a tail recursive style.
>
>Can the OCaml system tell me if a function is tail recursive?
>
>-Ram
>
>-------------------
>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


      parent reply	other threads:[~2003-08-31 10:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-30 22:52 [Caml-list] beginner question about tail recursion Ram Bhamidipaty
2003-08-31  6:33 ` Matt Gushee
2003-08-31  9:12   ` Remi Vanicat
2003-08-31 15:53     ` Matt Gushee
2003-08-31 10:31   ` skaller
2003-08-31 10:06 ` Warren Harris [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3F51C89B.1070802@pacbell.net \
    --to=wh232@pacbell.net \
    --cc=+caml+warren+a62ff5af68.ramb#sonic.net@spamgourmet.com \
    --cc=caml-list@pauillac.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox