|
Boost : |
Subject: Re: [boost] [local] this_ or _this?
From: Joel de Guzman (joel_at_[hidden])
Date: 2011-04-04 02:24:39
On 4/4/2011 1:34 PM, Joel de Guzman wrote:
> On 4/4/2011 1:00 PM, Thomas Heller wrote:
>> On Sun, Apr 3, 2011 at 8:28 PM, Lorenzo Caminiti<lorcaminiti_at_[hidden]> wrote:
>>> On Sun, Apr 3, 2011 at 2:22 PM, Steven Watanabe<watanabesj_at_[hidden]> wrote:
>>>> AMDG
>>>>
>>>> On 04/03/2011 11:13 AM, Lorenzo Caminiti wrote:
>>>>>
>>>>> Boost.Local uses a special name `this_` to access the object `this`
>>>>> bound from the enclosing scope. Shall this name be `this_` or `_this`
>>>>> according to Boost practices?
>>>>>
>>>>> struct c {
>>>>> void g(int x) { ... }
>>>>> void f() {
>>>>> void BOOST_LOCAL_FUNCTION_PARAMS( (int x) (bind this) ) {
>>>>> this_->g(x); //<<<<<<<<< Shall this be `_this->g(x);`
>>>>> instead?
>>>>> ...
>>>>> } BOOST_LOCAL_FUNCTIO_NAME(l)
>>>>> ...
>>>>> }
>>>>> ...
>>>>> };
>>>>>
>>>>> In particular, some library uses _ postfix for statements like
>>>>> mpl::if_ (not mpl::_if) while other uses _ prefix for variables like
>>>>> phoenix::local_names::_f (not local_names::f_).
>>>>>
>>>>
>>>> The convention is that _xxx is used for placeholders.
>>>> xxx_ is used when xxx is a keyword.
>>>
>>> I see, thanks. `this` is a keyword so Boost.Local should continue to
>>> use `this_` -- I'll add this to the docs rationale.
>>
>> I use _this for the placeholder to the current lambda in Boost.Phoenix
>
> Thomas, I strongly suggest that it be renamed to this_ for consistency.
I have to retract. Spirit too uses pre _ on *all* placeholders.
So, IMO, Thomas is right in choosing _this.
Regards.
-- Joel de Guzman http://www.boostpro.com http://boost-spirit.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk