Оптимизация хвостовой рекурсии в Oz

Другой случай, в дополнение к другим ответам, при создании одноэлементного сервиса - это - при передаче экземпляра сервиса в ServiceHost (в противоположность типу);

, Очевидно, поскольку Вы создаете экземпляр, который можно использовать какой бы ни конструктор;

Этот подход потребует добавления атрибута к Вашему сервису: [ServiceBehavior (InstanceContextMode. Единственный)];

7
задан Olivier Pirson 14 May 2015 в 13:03
поделиться

1 ответ

I am not too familiar with lazy functional languages, but if you think about the function Map in your question, it is easy to translate to a tail-recursive implementation if temporarily incomplete values in the heap are allowed (muted into more complete values one call at a time).

I have to assume that they are talking about this transformation in Oz. Lispers used to do this optimization by hand -- all values were mutable, in this case a function called setcdr would be used -- but you had to know what you were doing. Computers did not always have gigabytes of memory. It was justified to do this by hand, it arguably no longer is.

Back to your question, others modern languages do not do it automatically probably because it would be possible to observe the incomplete value while it is being built, and this must be what Oz has found a solution to. What other differences are there in Oz as compared to other languages that would explain it?

3
ответ дан 7 December 2019 в 05:25
поделиться
Другие вопросы по тегам:

Похожие вопросы: