Monday, September 3rd, 2007 12:41 am
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.
Page 1 of 3 << [1] [2] [3] >>
Monday, September 3rd, 2007 04:17 am (UTC)
Tail-call elimination is nice when the tail is known statically, but it is, as you said, just an optimization at that point.

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)

-- success continuation
type SK ans a = a -> FK ans -> ans
-- failure continuation
type FK ans = ans

-- LogicT is a monad transformer, where m is the type of the
-- monad to be transformed.  For example, LogicT IO a could 
-- include side effects as part of the computation of a
-- SFKT = "success/failure continuation thread"
newtype LogicT m a = SFKT (forall ans. SK (m ans) a -> FK (m ans) -> m ans)
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.
Monday, September 3rd, 2007 10:28 am (UTC)
Cool! In some sense, I suppose this is a more general version of drj11's answer below...
[identity profile] david jones (from livejournal.com)
Monday, September 3rd, 2007 07:36 am (UTC)
State machines.
Monday, September 3rd, 2007 10:27 am (UTC)
Aha! I knew there was a good answer somewhere.
(Anonymous)
Friday, May 20th, 2011 03:01 am (UTC)
They need to recognize if you clothed any of these conditions:

* 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]
(Anonymous)
Friday, May 20th, 2011 02:53 pm (UTC)
They need to know if you have any of these conditions:

* 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]
(Anonymous)
Sunday, May 22nd, 2011 09:31 pm (UTC)
No Prescriptions Needed.
[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]
(Anonymous)
Monday, May 23rd, 2011 12:05 am (UTC)
[url=http://pharmshop-online.com]cheap cialis without prescription[/url]! No complication how grey a man is, there compel come up a leisure when they will perceive it difficult (or unachievable) to achieve and/or maintain an erection. And while a fetter dominion experience as if it is the expiration of the existence, it is not. [url=http://pharmshop-online.com/buy_kamagra_en-us.html]cheap kamagra online usa[/url]
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].
(Anonymous)
Monday, May 23rd, 2011 11:57 pm (UTC)
[url=http://pharmshop-online.com]buy generic cialis pills online[/url]! No condition how grey a man is, there choice hit a leisure when they want find it difficult (or unachievable) to execute and/or state an erection. And while a fetter potency experience as if it is the end of the world, it is not. [url=http://pharmshop-online.com/buy_kamagra_en-us.html]buy cheap kamagra online usa[/url]
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].
(Anonymous)
Wednesday, May 25th, 2011 01:12 pm (UTC)
No Prescriptions Needed.
[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]
(Anonymous)
Thursday, June 9th, 2011 10:16 pm (UTC)
Приветствую! Вот тут нынче подумал - надо желание приобрести ассортимент карандашей чтобы своего чада - пусть развивается, рисует, творчеством вообщем занимается :) наткнулся на [url=http://orslon-nn.ru]интернет магазин детских канцтоваров[/url] - и заказал тут набор карандашей, фломастеров и ещё кучу только прикольного и полезного :) оказывается есть некие витражные краски, я самовольно в этом совсем не разбираюсь, но будем осмеливаться, штука вроде желание интересная) образование не стоит на месте и видимо он дошёл и предварительно детских красок, ныне они лопать разных видов, а не простой картина и гуашь словно в нашем детстве.
(Anonymous)
Thursday, June 16th, 2011 02:54 pm (UTC)
Здрасти! Может обретаться подскажете новичку который такое ИРК чат и как туда зайти?? У меня обычные чаты тормозят, друг посоветовал юзать [url=http://ircnn.ru]ирк чаты[/url], говорит ирк чат не тормозит, только ради него нужна отдельная программа, где её скачать? Ещё хочется для в чате было много народу, единодушно веселее и чтоб модераторов было поменьше ;) вообщем такая тема, сколько оказывается есть прикольные чаты, а про них никто не знает, наверное потому который они работают не будто весь, после сайт, а отдельно, вообщем буду изучать, относительный успехах отпишусь.
(Anonymous)
Thursday, July 7th, 2011 09:00 pm (UTC)
Приветствую! Вот тогда ныне подумал - полагается бы приобрести сортимент карандашей дабы своего чада - пусть развивается, рисует, творчеством вообщем занимается :) наткнулся на [url=http://orslon-nn.ru/index.php?productID=239]детские декор краски[/url] - и заказал тогда гарнитур карандашей, фломастеров и ещё кучу всего прикольного и полезного :) оказывается бранить некие витражные краски, я сам в этом схожий не разбираюсь, впрочем будем сметь, лицо вроде готовность интересная) улучшение не стоит ради месте и видимо он дошёл и сперва детских красок, днесь они есть разных видов, а не непринужденный картина и гуашь как в нашем детстве.
(Anonymous)
Saturday, July 16th, 2011 11:45 pm (UTC)
Приветики! Сломал я для днях принадлежащий старенький струйник hp, надоел он мне, кокнул я его вдребезги нафик, сызнова засох картридж баянно, решил я покупать наконецто лазерник, и решил что это довольно именно кэнон, достал меня хьюлет своим качеством( купил следовательно [url=http://komputernn.ru]лазерник canon[/url] и ныне даволин для всегда 100500! Установка драйвера заняла пару минут и вот принтер уже соглашаться к печати) сейчас я печатаю круг божий сутки и не знаю никаких трабл с картриджами =) заправки хватает почти для год и стоит она дёшево - триста рублёв и конец) рекомендую кэнон, ребяты.
(Anonymous)
Wednesday, July 20th, 2011 07:46 pm (UTC)
Привет! Я изнываю через жары, только в конечном счете намедни пришло мне случай - [url=http://yourconditions.ru]кондиционер[/url], он стоит менее 15 рублей вместе с установкой! я ужасно даводлин ;) причинность днесь градусов в моей квартире не 33, а 29 (градусник несомненно глючный), но четыре градуса меньше, спать дюже удобно теперь ;) приходится не забывать мыть кондей, пылесосить следует видный блок причинность он засоряется мусором, тополиным пухом и непохожий гадостью, а ещё следите воеже не заливало соседей из конденсатной трубки!
(Anonymous)
Friday, July 29th, 2011 12:16 am (UTC)
Благодеяние дряпня для территорию настоящих хакеров - [url=http://x-hack.ru]x-hack[/url] и простой любителей софта!
Тут вам понравится, можете не сомневаться, заходите для [url=http://x-hack.ru]x-hack.ru[/url]
Свежие обзоры софта и обсуждение ради огромном форуме, где вы узнаете страсть всего нового.
(Anonymous)
Wednesday, August 24th, 2011 12:53 pm (UTC)
[url=http://pharmshop-online.com]buy cialis pills 20mg online[/url] Cialis® is in a rank of drugs called Phosphodiesterase Enzyme Inhibitors. It is used to treat erection problems in men. Cialis® is manufactured through Eli Lilly. Generic Cialis Gentle is the medicine that combines two cardinal characteristics substantial for treating manly enervation (Erectile Dysfunction): rapid acting and prolonged effect. You can rob the medicament in the morning and be clever as a service to the right second during that date, evening or uniform during the next day. [url=http://pharmshop-online.com]buy generic cialis 20mg online[/url]
(Anonymous)
Sunday, August 28th, 2011 07:56 pm (UTC)
[url=http://pharmacyshop-online.com]generic viagra online no prescription[/url] Con this prescription before debouchment with a glass of water. The quantity is commonly charmed 1 hour in front earthy activity. You should not take the dose more than once per day. Do not understand your medicine more ordinarily than directed. This bibliography may not delineate all realizable interactions. Give your haleness carefulness providers a file of all the medicines, herbs, non-prescription drugs, or dietary supplements you use. [url=http://pharmacyshop-online.com]buy cheap viagra online no prescription[/url]
(Anonymous)
Monday, August 29th, 2011 01:40 pm (UTC)
[url=http://pharmacyshop-online.com]buy generic viagra online no prescription[/url] Con this medicine alongside express with a glass of water. The portion is customarily entranced 1 hour in advance progenitive activity. You should not book the measure more than every now per day. Do not take your nostrum more often than directed. This roster may not specify all plausible interactions. Give your vigour vigilance providers a bibliography of all the medicines, herbs, non-prescription drugs, or dietary supplements you use. [url=http://pharmacyshop-online.com]cheap viagra online no prescription[/url]
(Anonymous)
Friday, September 2nd, 2011 10:41 am (UTC)
[url=http://pharmacyshop-online.com]buy viagra online usa canada[/url] The inequality between a type reputation medicine and a generic sole is in the monicker, shape and in the price. A generic opiate is large called close to the favour of the effectual ingredient while a producer uses a brand name. Despite that, a industrialist cannot be born a patent for a set chemical intermediary, this is why manufacturers of generic medications can legally generate the pretended "generics". They are the even so chemically and since the lively ingredient is selfsame, they contain the word-for-word medical effect. Consequently buying a generic medication harmonious pays less but gets the very uniform result. [url=http://pharmacyshop-online.com]cheap generic viagra online[/url]
(Anonymous)
Sunday, September 4th, 2011 06:42 pm (UTC)
[url=http://onlinepharmacy-shop.com]buy cialis online
[/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]
(Anonymous)
Tuesday, September 6th, 2011 02:12 pm (UTC)
[url=http://onlinepharmacy-shop.coml]buy generic cialis[/url] Cialis® is in a class of drugs called Phosphodiesterase Enzyme Inhibitors. It is used to boon erection problems in men. Cialis® is manufactured during Eli Lilly. TADALAFIL is in use accustomed to to touch on erection problems in men. It works close dilating blood vessels in the penis, allowing the inflow of blood needed on an erection. Cialis®'s 36-hour effectiveness earned it the agnomen, "The Weekend Pilule". Also, Cialis® is currently in Phase 3 clinical trials after treating pulmonary arterial hypertension.
[url=http://onlinepharmacy-shop.com]buy generic cialis online[/url]
(Anonymous)
Tuesday, September 6th, 2011 07:53 pm (UTC)
[url=http://pharmacyshop-online.com]buy generic viagra usa[/url] Generic Viagra we put forward is close by in 50mg and 100mg tabs. These are fixed dosages of Sildenafil (the active ingredient) in the pills: thus a 50mg Viagra remedy contains 50 mg of Sildenafil congregate and a 100mg Viagra bolus contains 100mg of Sildenafil. The precept dose in favour of achieving the effect is a 50mg pill. Even so, the ingredient effects different people in a odd way so we would commend you to start with 25mg (split a 50mg troche in two and settle song half alone) to get a load of if this is sufficient for the benefit of you. If not - extract a mostly 50mg pill. [url=http://pharmacyshop-online.com]viagra online no prescription[/url]
(Anonymous)
Wednesday, September 7th, 2011 03:13 am (UTC)
[url=http://pharmacyshop-online.com]buy viagra online now[/url] As we play a joke on already mentioned that no producer can take manifest a conspicuous on account of a chemical agent. Thus generics can acquire the scrupulously unchanged vigorous ingredients as the brand pills. However, names and semblance (model and color) of medications can be and are as a last resort patented and should be treated as the thoughtful property. Thus using the rating and the shape of the variety pills a producer producing generic medications will be accused of the copyright infringement. This is why generic pills look bizarre, they are of a assorted color and be suffering with a discrete shape if compared to a manufacturer esteem pill. [url=http://pharmacyshop-online.com]cheap generic viagra online[/url]
(Anonymous)
Thursday, September 8th, 2011 05:28 pm (UTC)
[url=http://pharmacyshop-online.com]cheap viagra online now[/url] The difference between a trade mark respect remedy and a generic in unison is in the repute, status and in the price. A generic cure-all is usually called by the name of the effectual ingredient while a fabricator uses a type name. Though, a industrialist cannot possess a licence after a unfluctuating chemical agent, this is why manufacturers of generic medications can legally generate the misdesignated "generics". They are the at any rate chemically and since the acting ingredient is identical, they receive the constant medical effect. As a consequence buying a generic medication everyone pays less but gets the very selfsame result. [url=http://pharmacyshop-online.com]generic viagra pills online usa[/url]
(Anonymous)
Saturday, September 10th, 2011 01:00 am (UTC)
[url=http://pharmacyshop-online.com]buy viagra 20mg online[/url] The variation between a characterize fame medication and a generic in unison is in the esteem, figure and in the price. A generic cure is usually called nigh the mention of the effective ingredient while a fabricator uses a trade mark name. However, a maker cannot be imbued a patent for a undoubted chemical spokesman, this is why manufacturers of generic medications can legally produce the supposed "generics". They are the at any rate chemically and since the acting ingredient is matching, they bear the but medical effect. Thus buying a generic medication everyone pays less but gets the unusually unaltered result. [url=http://pharmacyshop-online.com]cheap viagra usa no prescription[/url]
(Anonymous)
Tuesday, September 13th, 2011 04:05 am (UTC)
[url=http://pharmacyshop-online.com]buy generic viagra no prescription[/url] Strident quality of the medications we bid is the subject of our educate concern. The good is hugely straightforward: the less ill the grade of goods is, the more customers we have. Event we are really respectful and discerning in the realm of possibilities of the supplier, the importance of goods is thoroughly tested and the documentation is closely checked. The medications are manufactured in India nigh an Indian shape licensed, Indian FDA approved company. Each carton of the products we sent completed includes the Certificate of Analysis obtained from the industrialist's laboratory and fully adheres to the Indian law. [url=http://pharmacyshop-online.com]buy generic viagra usa[/url]
Page 1 of 3 << [1] [2] [3] >>