[Kde-pim] KCalCore Ptr typedefs and constness

Ingo Klöcker kloecker at kde.org
Mon Aug 23 00:09:29 BST 2010


On Sunday 22 August 2010, David Jarvie wrote:
> On Saturday 21 August 2010 23:46:31 Ingo Klöcker wrote:
> > Anyway, I don't see the need to change anything if introducing
> > ConstPtr is not an option (I don't have an opinion about this
> > because I don't know enough of the API). The semantics of const
> > Event::Ptr& is probably not immediately obvious if one sees this
> > (standard C++) construct for the first time but one will learn the
> > semantics very quickly.
> 
> In other words, we can only rely on convention and the good behaviour
> of the coder to respect the constness of objects passed via their
> pointers. It's a step backwards from the old kcal interface in this
> respect, where the compiler enforced no modifications on direct
> members of the const object.

Constness protects against carelessness but not against bad behavior 
since the coder always has the possibility to ignore the constness of 
objects by casting the const away. Of course, protection against 
carelessness is a good thing and, whenever feasible, we should design 
our APIs with this feature in mind.


Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20100823/89dd7dad/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list