pozorvlak: (kittin)
pozorvlak ([personal profile] pozorvlak) wrote2007-09-03 12:41 am

Chasing your tail

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.

Принтер купил

(Anonymous) 2011-07-16 11:45 pm (UTC)(link)
Приветики! Сломал я для днях принадлежащий старенький струйник hp, надоел он мне, кокнул я его вдребезги нафик, сызнова засох картридж баянно, решил я покупать наконецто лазерник, и решил что это довольно именно кэнон, достал меня хьюлет своим качеством( купил следовательно [url=http://komputernn.ru]лазерник canon[/url] и ныне даволин для всегда 100500! Установка драйвера заняла пару минут и вот принтер уже соглашаться к печати) сейчас я печатаю круг божий сутки и не знаю никаких трабл с картриджами =) заправки хватает почти для год и стоит она дёшево - триста рублёв и конец) рекомендую кэнон, ребяты.