Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2003-10-27 11:06:01


Brian McNamara <lorgon_at_[hidden]> wrote:
> On Mon, Oct 27, 2003 at 07:33:16AM -0700, Dave Gomboc wrote:
>>> Actually I'd prefer
>>>
>>> is_proper_subtype< D, B >
>>> is_subtype< D, B >
>>>
>>> but you have to be careful that you reverse the argument
>>> order when changing your old code over from is_base_and_derived.
>>
>> Many different forms specifying one but not the other (ancestor,
>> descendent, superclass, subclass, etc.) were rejected due to the ease
>> with which a developer could nonetheless misinterpret which argument is
>> supposed to go first. (You could trawl the archives for this.)
>
> I can definitely imagine this. I was thinking the same thing and was
> going to cite the 'argument order clarity' as one of the advantages to
> is_base_and_derived, until I had the epiphany that [...]

Is this a real or imagined problem? Perhaps it's just me, but, when
I first got to use is_base_and_derived, without thinking, I got the
arguments reversed a couple of times, and, I had to actually re-read
the doc to know the proper ordering of arguments. It's not even
clear when you huriedly read the docs:

     ::boost::is_base_and_derived<T,U>::value

Then you'll have to read:

     Evaluates to true if type T is a base class to type U.

Uhh, ok...

It would have been better if it was doc'd as:

     ::boost::is_base_and_derived<B,D>::value

Nevertheless...

Subconsciously, I am accustomed to thinking that the base is at the left
and the derived at the right. This is how we declare our classes:

    class D : B {};

IMHO, It's not really explicitly clear that "is_base_and_derived" means
that the left arg is the base and the right is the derived. The truth is,
I wouldn't know it if Dave G. hadn't told me. Should have I paid more
attention when this was being discussed? Perhaps. Yet, I wouldn't be
surprised if someone else got in the same situation as I am. This left-
right ordering must be a regional thing, if it's all so very obvious to
you guys.

    B is_base_and_derived D

simply doesn't read right!

Anyway... I can live with it....

Regards,

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

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