Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: block-based programming...

by flyingmoose (Priest)
on Apr 22, 2004 at 16:54 UTC ( [id://347411]=note: print w/replies, xml ) Need Help??


in reply to Re: block-based programming...
in thread block-based programming...

So can you give me a list of languages that do/don't eliminate tail recursion automatically? Do you have that list memorized? What gcc versions? MSVC? How about java (some JVM's can, some can't). Does Fortran? What about pascal? COBOL? Python (doesn't)? Where are the efficiency tradeoffs in those various language? Is tail recursion ever faster? (never). How does Perl handle it? What about Ruby? One really can't keep this straight -- especially if you don't confine yourself to a very narrow field of languages. All the more reason to be explicit.

This also goes back to my earlier comments about being blunt and forthright with code. Tail-recursion isn't natural in this case. In math, it's natural, but where a loop applies, use the loop. So why do it? What is the value there?

Again, like the other argument, our neurons are wired differently and I doubt we will reach agreement.

Replies are listed 'Best First'.
Re: block-based programming...
by Abigail-II (Bishop) on Apr 22, 2004 at 17:20 UTC
    Oh, now you're suddenly concerned about languages. What has 'real hardware' (whatever that means) to do with it? And why would I have to memorize which compilers eliminate tail recursion? That's as useful as to memorize which compilers or languages exist. But rest assured that when I use a compiler and make use of tail recursion, I know whether it will eliminate it or not. Which is all I need to know.

    This also goes back to my earlier comments about being blunt and forthright with code. Tail-recursion isn't natural in this case.
    If you want to discuss specific cases, then be specific. I didn't argue that tail recursion was ok in this example. Tail recursion was bad in this example. But you extended it to make some general remarks about tail recursion, and that's where I disagree.

    Abigail

      real hardware meant running the code in real life versus on theoretical 'mental' computers. That is, the concept of believing in an infinite stack when reading pseudocode is an error a lot of folks (but probably not you) make.

      But rest assured that when I use a compiler and make use of tail recursion, I know whether it will eliminate it or not

      Again, this is good for your work, but I do not rest assured people I work with are this smart, nor do I think everyone who takes some of my code (open source, etc) would be this smart. I write C code that has to run on about 10 different platforms, so I guess my domain might lend me more towards paranoia.

      I didn't argue that tail recursion was ok in this example. Tail recursion was bad in this example. But you extended it to make some general remarks about tail recursion, and that's where I disagree.

      No prob, that was a failure to communicate on my part. There are certaintly algorithms that are best expressed recursively (this is obvious!), but I don't ever think it's a good idea for replacing an infinite (or even long running) loop with a recursive solution just because you can and the compiler is smarter than you ... again, obvious to some, but not to all. A better example of using recursion is in math examples, which I have mentioned, and there are tons of doing things in different ways in Lisp, where that becomes the normal idiom.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://347411]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-23 22:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found