Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-07-26 06:27:55


David Abrahams wrote:
> "Peter Dimov" <pdimov_at_[hidden]> writes:
>
>>>> I prefer to be able to name the lock variable 'lock' instead of
>>>> 'lk'.
>>>
>>> Suit yourself, but I think variable names should denote roles, not
>>> types.
>>
>> Hm. What is it that makes 'lock' not qualify as a role?
>
> Well, OK, it's a role at a very low level of abstraction. Something
> more like "access_foo" for some mutex-protected resource "foo" might
> be better.

Compare:

    lock lk( m ); // the original examples

with

    scoped_lock lock( m );

Or the role-based variation:

    lock access_foo( foo_mutex );

with

    scoped_lock foo_lock( foo_mutex );

Same but unnamed (because you won't be touching the lock afterwards):

    lock access( foo_mutex );

vs

    scoped_lock lock( foo_mutex );


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk