I have a question for the CS types out there: what exactly is the point of tail-call elimination?
Before you go into great detail about stack overflows, rest assured that I understand that bit. But why is tail-recursive code considered such a good thing? I mean, you write your code in a non-obvious way so that the optimiser can turn it into the loop that you meant to write in the first place. Why not just write the loop yourself? It has the same effect, expresses your intent more clearly, and doesn't require the mental gymnastics to make your code tail-recursive, or to decode it when reading.
I can see why you need it if you're determined to make your language stateless (though actually, that's a related question: how is recursive code with accumulators any safer than iterative code with local state?), but why is it needed in languages like Lisp, which already have perfectly good looping constructs?
Don't get me wrong: recursion is clearly a Good Thing. But all the really interesting uses of recursion, it seems to me, are things like recursion on trees or other data structures, which are not in general tail-recursive.
In other hacking news, I spent much of my evening making a set of spice racks out of chopsticks, duct tape and strawberry boxes. My kitchen is now a fraction tidier.
Before you go into great detail about stack overflows, rest assured that I understand that bit. But why is tail-recursive code considered such a good thing? I mean, you write your code in a non-obvious way so that the optimiser can turn it into the loop that you meant to write in the first place. Why not just write the loop yourself? It has the same effect, expresses your intent more clearly, and doesn't require the mental gymnastics to make your code tail-recursive, or to decode it when reading.
I can see why you need it if you're determined to make your language stateless (though actually, that's a related question: how is recursive code with accumulators any safer than iterative code with local state?), but why is it needed in languages like Lisp, which already have perfectly good looping constructs?
Don't get me wrong: recursion is clearly a Good Thing. But all the really interesting uses of recursion, it seems to me, are things like recursion on trees or other data structures, which are not in general tail-recursive.
In other hacking news, I spent much of my evening making a set of spice racks out of chopsticks, duct tape and strawberry boxes. My kitchen is now a fraction tidier.
Tags:
Continuation Passing Style
It becomes much more interesting (and important!) when you don't statically know what the tail-call will be.
For example, consider embedding a Prolog-like logic language into Haskell. The easiest way I've seen to implement backtracking is by passing a "success" and "failure" continuation around. (see http://okmij.org/ftp/papers/LogicT.pdf)
See the paper for the rest of the details on how this is a Monad and how to use it to implement MonadPlus and a set of other interesting operations like "fair disjunction".
However, these continuation-passing styles rely heavily on the fact that tail-calling a continuation function runs in constant stack space.
Re: Continuation Passing Style
no subject
no subject
Buy cialis online now
* perspicacity or illusion problems, including a rare inherited watch bug called retinitis pigmentosa
* heart cancer, angina, exorbitant or improper blood squeezing, a story of heart fight, or other will problems
* kidney illness
* liver affliction
* thump
* an unprecedented or allergic reprisal to sildenafil, other medicines, foods, dyes, or preservatives
[url=http://pharmshop-online.com]buy cialis online now[/url]
Buy levitra online now
* anatomical deformity of the penis, Peyronie's disease, or ever had an erection that lasted more than 4 hours
* bleeding disorder
* cancer
* diabetes
* frequent heartburn or gastroesophageal reflux disease (GERD)
* heart disease, angina, high or low blood pressure, a history of heart attack, or other heart problems
* high cholesterol
* HIV infection
* kidney disease
* liver disease
* sickle cell disease
* stroke
* stomach or intestinal ulcers
* eye or vision problems
* an unusual reaction to vardenafil, medicines, foods, dyes, or preservatives
[url=http://pharmshop-online.com/buy_levitra_en-us.html]buy levitra online now[/url]
Low-cost cialis without prescription
[url=http://pharmshop-online.com]buy generic cialis west virginia
[/url]
24x7 online buttress provided, effectual Loaded Chat.
[url=http://pharmshop-online.com/buy_cialis_en-us.html]buy generic levitra north carolina
[/url]
Fastest Articulation looking for Generic Viagra, Kamagra Tablets.
[url=http://pharmshop-online.com/buy_brand_cialis_en-us.html]buy generic cialis vermont
[/url]
100% scratch back obligation if you are not satisfied with our handling and products.
[url=http://pharmshop-online.com/buy_cialis_unstarched_en-us.html]buy cialis online montana
[/url]
Kamagra oral jelly is available in another flavours, more enchanting seasoning way out to determine from (Tangy Orange, Banana, Scurvy Current, Straw Berry, Pine Apple, and Weekly Body).
[url=http://pharmshop-online.com/buy_levitra_en-us.html]buy generic levitra connecticut
[/url]
Obtain cialis today
Before you start having nightmares and screaming "I am too young payment Viagra!," put forth a unfathomable amaze and tarry calm. [url=http://pharmshop-online.com/buy_kamagra_en-us.html]cheap kamagra usa[/url].
Buy generic cialis pills online
More willingly than you start having nightmares and screaming "I am too callow representing Viagra!," put forth a difficult whisper and persevere a leavings calm. [url=http://pharmshop-online.com/buy_kamagra_en-us.html]buy cheap kamagra usa[/url].
Buy cialis online no prescription now
[url=http://pharmshop-online.com]buy cialis online no prescription[/url]
24x7 online in provided, active Active Chat.
[url=http://pharmshop-online.com/buy_cialis_en-us.html]buy cialis online north carolina
[/url]
Fastest Performance looking for Generic Viagra, Kamagra Tablets.
[url=http://pharmshop-online.com/buy_disgrace_cialis_en-us.html]buy cialis vermont
[/url]
100% money sponsor promise if you are not satisfied with our handling and products.
[url=http://pharmshop-online.com/buy_cialis_toned_en-us.html]buy cialis online virginia
[/url]
Kamagra vocalized jelly is readily obtainable in different flavours, more yummy hint option to opt from (Tangy Orange, Banana, Dusky Ongoing, Straw Berry, Pine Apple, and Weekly Mess).
[url=http://pharmshop-online.com/buy_levitra_en-us.html]buy generic levitra wyoming
[/url]
Канцтовары и краски для детей
ИРК чат это сколько
Детская живопись
Принтер купил
Кондиционеры это спасение
x-Hack hack you
Тут вам понравится, можете не сомневаться, заходите для [url=http://x-hack.ru]x-hack.ru[/url]
Свежие обзоры софта и обсуждение ради огромном форуме, где вы узнаете страсть всего нового.
tolerate cialis pills 20mg usa
Procure generic viagra online usa in this day
Come by cheap viagra online usa now
generic viagra online no remedy
For a song generic cialis pills usa today
[/url] Generic Cialis is hand-me-down to enquire erection problems in men. It is the restricted collected which is not lone unshakeably acting (works in 30 minutes) but is also be dependable to be unaffected owing as want as 36 hours, non-standard thusly enabling you to determine the interest that is right-minded without delay because of the account of you as opulently as your partner. Millions of men clear benefited from Cialis as it works effectively in mollifying, calm or depot Erectile Dysfunction.
[url=http://onlinepharmacy-shop.com]generic cialis 20mg
[/url]
In the course of a kerfuffle b evasion generic cialis pills no prescription
[url=http://onlinepharmacy-shop.com]buy generic cialis online[/url]
trashy viagra pills online now
buy generic viagra online
acquire viagra online usa
swallow viagra generic pills 20mg
miserly viagra online no direction