From: Tomoyuki Tanaka
Subject: is my cc tail-recursive?
Date: 
Message-ID: <6g7hce$evu$1@mark.ucdavis.edu>
(i appreciate the responses to my C questions.)

i'm wondering if the cc i'm using (/opt/pkg/SUNWspro/bin/cc) is
(properly?) tail-recursive.

right now, i'm using goto's in case it's not.


--
;;; TANAKA Tomoyuki   ("Mr. Tanaka" or "Tomoyuki")
;;; http://www.cs.indiana.edu/hyplan/tanaka.html

From: firewind
Subject: Re: is my cc tail-recursive?
Date: 
Message-ID: <Pine.LNX.3.95.980405120428.200A-100000@metroid.dyn.ml.org>
On 5 Apr 1998, Tomoyuki Tanaka wrote:

> i'm wondering if the cc i'm using (/opt/pkg/SUNWspro/bin/cc) is
> (properly?) tail-recursive.

We don't know. Go ask Sun.

> right now, i'm using goto's in case it's not.

*cough*

-- 
(initiator of the campaign for grumpiness where grumpiness is due in c.l.c)

Having newsserver problems at the moment-- argh!
From: Dr Richard A. O'Keefe
Subject: Re: is my cc tail-recursive?
Date: 
Message-ID: <3529891E.4A22@atlas.otago.ac.nz>
Tomoyuki Tanaka wrote:
> 
> (i appreciate the responses to my C questions.)
> 
> i'm wondering if the cc i'm using (/opt/pkg/SUNWspro/bin/cc) is
> (properly?) tail-recursive.

Er, why not ask Sun?  The compilers are normally installed under
/opt/SUNWspro, not /opt/pkg/SUNWspro.  Indeed, if you fish around
in there, you'll find READMEs/c which in section E points you to
	file:/opt/SUNWspro/DOC4.0/lib/local/C/html_docs/index.html

If you don't want to look at the printed manuals, and you don't want
to look at the HTML manuals, and you don't want to look at the
AnswerBook manuals, you could try an experiment.  If you take the
trouble to try a tiny experiment, you will find that the current
SPARCompiler 4.2 C compiler _does_ know about tail calls.  Don't
be confused by the tail call code, it uses the 'call' instruction,
but mainly as a reliabel long-distance jump.

I don't know exactly what _you_ mean by 'properly' tail-recursive,
but Sun's C compiler handles all tail calls where the current frame
is not actually needed (e.g. if you have a local variable which you
pass by reference in a tail call, the current frame has to be
retained).  It is _not_ restricted to tail _recursion_.

Beware that at the higher optimisation levels the SPARCompilers
do automatic inlining, which may make the results harder to see
in the experimental code.
From: Tomoyuki Tanaka
Subject: Re: is my cc tail-recursive?
Date: 
Message-ID: <6gcrc4$95i$1@mark.ucdavis.edu>
In article <·············@atlas.otago.ac.nz>,
Dr Richard A. O'Keefe <··@atlas.otago.ac.nz> wrote:
>
>I don't know exactly what _you_ mean by 'properly' tail-recursive,

i think that's what Lisp ppl used to call those compilers.


> It is _not_ restricted to tail _recursion_.

very true about "It is _not_ restricted to tail _recursion_."
but Lisp ppl called it "tail recursive" compilers.


> (e.g. if you have a local variable which you pass by reference
> in a tail call, the current frame has to be retained).

do some C compilers do "call by reference"?
From: Tomoyuki Tanaka
Subject: Re: is my cc tail-recursive?
Date: 
Message-ID: <6gcrkq$9cp$1@mark.ucdavis.edu>
>> (e.g. if you have a local variable which you pass by reference
>> in a tail call, the current frame has to be retained).
>
>do some C compilers do "call by reference"?
>

ok, i get it.

swap(&a, &b); in tail position.


-- 
;;; TANAKA Tomoyuki   ("Mr. Tanaka" or "Tomoyuki")
;;; http://www.cs.indiana.edu/hyplan/tanaka.html