|
Boost : |
Subject: Re: [boost] Case study: Boost.Local versus Boost.Phoenix
From: Gregory Crosswhite (gcross_at_[hidden])
Date: 2011-02-04 13:45:00
On 2/4/11 10:33 AM, Hartmut Kaiser wrote:
> That's purely a choice based on personal taste.
>
I am perfectly fine with that conclusion, as long as people aren't
calling my code horrible. :-)
> Just my 2c: I find the proposed macro syntax to be ugly, unreadable and very
> difficult to associate with the corresponding function definition.
>
I thought so at first, but it didn't take very long to get used to it.
>>> 3. Easier to debug and see compiler's error messages
>> The error messages usually aren't that bad for Boost.Local, and the syntax
>> is simple enough that I found it relatively easy to figure out what went
>> wrong compared to many other libraries.
> Again, that's a matter of taste. I find macros to be more difficult to debug
> than normal code. You normally can't step through macro code.
>
In this case it is really not a matter of taste, but rather it is a
matter of having an error message that is just a few lines long and
points you in the direction of what you did wrong versus an error
message that is thousands of lines long and gives you no useful
information at all. :-)
If you have never used Boost.Local then you will just have to trust me
that the error messages are not as cryptic as you (understandably) seem
to expect they should be given that the implementation uses macros.
> FWIW, I prefer using lambda/phoenix for simple expressions and I tend to
> write phoenix functions for more complex things. Working with lazy PFO's has
> the general advantage to allow for easy function composition, which is a
> major advantage over plain adhoc 'local functions' as defined by your
> library.
First, you might already know this but just to clarify: this library is
not mine and I have contributed nothing to it except support. This
library is one that I picked up after it was advertised a couple of
months ago and grew to really like because it scratched a major itch.
Second, your arguments sounds a bit to me like saying that one should
not use the cryptic macro BOOST_FOREACH when one can use the Boost.Range
functions with Phoenix functions. Yes, it is true that there are many
times where Phoenix functions may be the better solution, but sometimes
you just want to write a for loop over a range using a standard C++
block for the body and it is awfully nice to have a macro that makes
that easy. :-)
Cheers,
Greg
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk