[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: KColorScheme - additional (convenience) ctors
From:       Simon Hausmann <hausmann () kde ! org>
Date:       2007-09-04 10:36:09
Message-ID: 200709041236.13277.hausmann () kde ! org
[Download RAW message or body]


On Sunday 02 September 2007 20:06:12 Matthew Woehlke wrote:
> Simon Hausmann wrote:
> > I suggest to change the signature of the constructor that takes a const
> > QWidget & to take a const QWidget *. Nobody passes around QWidget
> > references, so everyone using this constructor has to dereference the
> > widget to pass for no good reason IMHO.
>
> Thanks for the feedback. I thought about that also, the problem is that
> passing a NULL reference is not valid. By requiring a reference rather
> than a pointer, this makes it explicitly clear that you must pass in a
> real object. Otherwise, the ctor has to either throw an exception or
> abort(), neither of which it currently does.
>
> So I guess my preference is to make people type an extra '*' (and to
> force them to stop and think about what they're doing, which they need
> to be doing either way). But I'm willing to reconsider. Which evil is
> lesser?

I don't think you gain any readability from requiring people to write the *. 
It just seems inconsistent to me. QLayout::addWidget takes a QWidget pointer, 
too, even though it doesn't make sense to pass a null pointer to it.

Simon

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic