Re: Term Rewriting vs. Functional Programming
- From: Vesa Karvonen <vesa.karvonen@xxxxxxxxxxxxxx>
- Date: 12 Sep 2005 15:21:41 GMT
Matthias Blume <find@xxxxxxxxxxxxxxxxxxxx> wrote:
> Vesa Karvonen <vesa.karvonen@xxxxxxxxxxxxxx> writes:
> One reason is that without a more thorough account for _all_ space
> usage, there is not much point in specifying it. Consider the
> following program:
> let fun f x = f (1 + x)
> in f 0
> end
> You would expect that with the requirement for tail-call elimination
> in place, this code would run in constant space (until it overflows
> the integer range), right?
Like you say, it depends on the function that + is bound to.
Frankly, I find this "hidden assumption" argument a bit silly. It is quite
clear to me (and I assume to most) that you can write programs that are
tail recursive, but will always consume arbitrary amounts of space. Here
is a much clearer example:
val bs : bool list ref = ref []
fun loop b = (bs := b :: !bs ; loop (not b))
val () = loop true
> In SML/NJ, "stack overflow" and "heap overflow" are the same thing.
I know, but I can't see how it would make the case for tail call
elimination (or space safety in general) any less important. I find it
crucial to be able to reason about space requirements. The difference
between O(1) and O(n) space usage is not insignificant.
> You seem to assume that the stack of the abstract machine implied by
> the OpSem in the definition is meant to have a manifest counterpart
[No, I don't.]
> Those are assumptions about implementations which are likely true, but
> which, if you want to require them, would take a whole lot more
> specification work.
I would personally be happy with a semi-formal specification. "I know tail
call elimination when I see it." (-:
-Vesa Karvonen
.
- Follow-Ups:
- Re: Term Rewriting vs. Functional Programming
- From: Matthias Blume
- Re: Term Rewriting vs. Functional Programming
- References:
- Re: Term Rewriting vs. Functional Programming
- From: Jon Harrop
- Re: Term Rewriting vs. Functional Programming
- From: Vesa Karvonen
- Re: Term Rewriting vs. Functional Programming
- From: Paul Rubin
- Re: Term Rewriting vs. Functional Programming
- From: Vesa Karvonen
- Re: Term Rewriting vs. Functional Programming
- From: Marcin 'Qrczak' Kowalczyk
- Re: Term Rewriting vs. Functional Programming
- From: Vesa Karvonen
- Re: Term Rewriting vs. Functional Programming
- From: Peter G. Hancock
- Re: Term Rewriting vs. Functional Programming
- From: Vesa Karvonen
- Re: Term Rewriting vs. Functional Programming
- From: Andreas Rossberg
- Re: Term Rewriting vs. Functional Programming
- From: Vesa Karvonen
- Re: Term Rewriting vs. Functional Programming
- From: Matthias Blume
- Re: Term Rewriting vs. Functional Programming
- Prev by Date: Re: Term Rewriting vs. Functional Programming
- Next by Date: Re: Term Rewriting vs. Functional Programming
- Previous by thread: Re: Term Rewriting vs. Functional Programming
- Next by thread: Re: Term Rewriting vs. Functional Programming
- Index(es):
Relevant Pages
|