DIP: Tail call optimization
Stefan Koch via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Sun Jul 10 01:36:23 PDT 2016
On Sunday, 10 July 2016 at 07:43:14 UTC, ketmar wrote:
>
> we already has one optimization case speced -- NRVO. and it is
> BAD. adding another implementation detail to the spec will only
> worsen the situation, i believe.
We have other cases cases where optimization is expected but it
is poorly speced.
However I like the fact that the spec does demand some
optimizations because it ensures the quality of a conforming
implementation.
Yet, TCO in particular it not applicable directly in many cases,
and usually needs many transformations before it can be applied.
There nothing wrong with guaranteeing that it will be applied in
trivial cases.
(This should be done by adding a sentence to the spec, not by
adding a pargma)
However for more complex cases it heavily depends on the
optimizer and on the backend!
In general you don't want to relay in such optimizations.
When in doubt avoid recursion.
More information about the Digitalmars-d-announce
mailing list