Learning Haskell makes you a better programmer?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed Dec 26 09:02:43 PST 2012
On 12/26/12 11:34 AM, Russel Winder wrote:
> On Wed, 2012-12-26 at 11:03 -0500, Andrei Alexandrescu wrote:
>> On 12/26/12 9:42 AM, Russel Winder wrote:
> […]
>>> Does D do tail recursion optimisation?
>>
>> Yah, but not tail calls. (That should be on the list...)
>
> I'll have to admit confusion from the above statement: tail calls are a
> programmer technique, tail call optimization is a compiler / run time
> technique. If a programmer uses tail calls and the compiler realizes
> tail call optimization then the result is equivalent to iteration.
A few rough definitions:
Tail recursion: the last evaluation performed in a branch of a function
is a call to itself.
Tail recursion optimization: replace tail recursion with a GOTO the
entry point of the function.
Tail call: the last evaluation performed in a branch of a function is a
call to another function.
Tail call optimization: replace tail call with a GOTO the entry point of
the called function.
>>> Can the D compiler check to enforce *NO* (or at the worst single)
>>> assignment to a variable?
>>
>> Only for immutable data.
>
> But isn't that the whole point, in functional programming there is only
> immutable data. Thus a programming language that allows mutable data
> cannot really be said to be usable for functional programming style.
Yah, that's the whole point so we're in good shape there.
> On the other hand it is 2012-12-26T16:32 and nearly time for fireworks,
> and drinkies. Hopefully everyone is having a peaceful and happy
> Solstice/Xmas/New Year/Hogmanay/<insert your personal choice of excuse
> for celebration>.
Same to all from yours truly!
Andrei
More information about the Digitalmars-d
mailing list