Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Recursion or loop, design questions Date: Sat, 18 Jul 2015 16:26:53 -0700 Organization: None to speak of Lines: 37 Message-ID: References: <5f394a20-64ec-4a15-9d2b-a8363fcbb248@googlegroups.com> <87oajce0uv.fsf@bsb.me.uk> <87mvyvc5a8.fsf@bsb.me.uk> <87wpxxby1o.fsf@bsb.me.uk> <644aa8d6-46f4-474f-a668-a5a8990f37e2@googlegroups.com> <87380l9pi7.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="18899"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+0MUs4mbTkHxvV1Sspq/6F" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:SW1xwjU2E47PVyEEzhD2vIo23S8= sha1:s4tSCOUuARtDSeB6Sv8ri5hZOLE= Xref: csiph.com comp.lang.c:65873 Malcolm McLean writes: > On Saturday, July 18, 2015 at 11:44:40 PM UTC+1, Keith Thompson wrote: >> Malcolm McLean writes: >> >> >> You're suggesting a language in which a function is called before its >> arguments are evaluated? I fail to see how that could make sense. >> > There are two approaches. > > The C way is to say that the programmer has called foo with 2 =2 > > foo(2+2); > > Ok, says the compiler. 2 +4 make 4. So what I'll do is generate a > call to foo with 4. > > The other way is to say the programmer has called foo with 2+2. > > Ok, says the compiler. foo takes the parameter foo(x). So, anywhere > I see x in foo, I'll replace it with 2+2. > > For simple functions, it makes no difference. But the second method > is more powerful if you want to do fancy things. You're talking about call-by-name (which C doesn't support, though you can emulate it with function pointers). Still, in the case of a call like f(g(), h()), the calls to g() and h() still must occur before f() returns (assuming f refers to its arguments), so it still wouldn't make for a tail-recursive call. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"