Re: Boost.Phoenix
От: PM  
Дата: 29.12.14 10:25
Оценка: 10 (2) +1
Здравствуйте, x-code, Вы писали:

XC>И в целом вся библиотека для чего?


Из уже упомянутой в той теме книги The Boost C++ libraries:

Boost.Phoenix is the most important Boost library for functional programming. While libraries like Boost.Bind or Boost.Lambda provide some support for functional programming, Boost.Phoenix includes the features of these libraries and goes beyond them.

In functional programming, functions are objects and can be processed like objects. With Boost.Phoenix, it is possible for a function to return another function as a result. It is also possible to pass a function as a parameter to another function. Because functions are objects, it’s possible to distinguish between instantiation and execution. Accessing a function isn’t equal to executing it.


В эпоху до С++11 вероятно имела некоторый смысл, сейчас при наличии лямбд и std::function мне кажется неактульной. Из той же книги:

Tip

Don’t use Boost.Phoenix to create complex functions. It is better to use lambda functions from C++11. While Boost.Phoenix comes close to C++ syntax, using keywords like if_ or code blocks between square brackets doesn’t necessarily improve readability.


Я когда-то пытался воспользоваться Boost.Phoenix для semantic action в парсере на Boost.Spririt, но код быстро стал нечитаемым, так что пришлось сделать обычный function object.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.