From: skaller <skaller@users.sourceforge.net>
To: William Lovas <wlovas@stwing.upenn.edu>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] List.rev
Date: 01 May 2004 18:10:18 +1000 [thread overview]
Message-ID: <1083399017.20722.25.camel@pelican.wigram> (raw)
In-Reply-To: <20040501070844.GB19707@force.stwing.upenn.edu>
On Sat, 2004-05-01 at 17:08, William Lovas wrote:
> In many functional languages, O'Caml included, it's assumed that tail calls
> are optimized to jumps, so that tail recursive functions do not allocate
> any stack space for each recursive call. (I believe in Scheme this is even
> included in the language specification.)
>
> With that in mind, you can read "This function is not tail recursive" as a
> behavioral specification, "This function might terminate abnormally due to
> stack overflow" -- and that's a useful side effect to document.
Indeed. I know that. But it is suboptimal.
There are better ways to write specifications
that (a) refer to an implementation that isn't exhibited
and (b) assume tail-rec implies no stack allocation
The first is called 'ill formed formula', and
the second is called 'unwarranted assumption'.
So the spec is (a) meaningless gibberish
and (b) even if the implementation were exhibited
it says nothing about the performance.
Yet it is easy enough to say
O(n) time and O(1) stack
and mean that this is a *requirement* on the implementation
and a guarrantee to the programmer.
That is the intent, why not say it?
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
-------------------
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
next prev parent reply other threads:[~2004-05-01 8:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-30 17:54 [Caml-list] "List.index" or "List.unique" functions? Rahul Siddharthan
2004-04-30 18:51 ` Martin Jambon
2004-04-30 19:01 ` Benjamin Geer
2004-04-30 19:07 ` Thanks " Rahul Siddharthan
2004-04-30 19:08 ` Karl Zilles
2004-04-30 19:29 ` Matthieu Sozeau
2004-04-30 20:01 ` Karl Zilles
2004-04-30 20:05 ` Remi Vanicat
2004-04-30 20:47 ` JM Nunes
2004-04-30 20:58 ` Karl Zilles
2004-05-01 1:59 ` [Caml-list] List.rev skaller
2004-05-01 4:18 ` Jon Harrop
2004-05-01 4:38 ` brogoff
2004-05-01 5:12 ` skaller
2004-05-01 7:08 ` William Lovas
2004-05-01 8:10 ` skaller [this message]
2004-05-01 8:32 ` Jon Harrop
2004-05-01 9:24 ` skaller
2004-05-02 12:07 ` Andreas Rossberg
2004-05-02 13:29 ` skaller
2004-05-01 10:07 ` Richard Jones
2004-05-01 10:09 ` Nicolas Cannasse
2004-05-02 16:04 ` Brian Hurt
2004-05-01 10:32 ` Jon Harrop
2004-05-01 16:41 ` John Goerzen
2004-05-01 19:11 ` skaller
2004-05-01 10:03 ` [Caml-list] "List.index" or "List.unique" functions? Richard Jones
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=1083399017.20722.25.camel@pelican.wigram \
--to=skaller@users.sourceforge.net \
--cc=caml-list@inria.fr \
--cc=wlovas@stwing.upenn.edu \
/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