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

List:       koffice-devel
Subject:    Re: structs vs classes; was Re: koffice/kspread
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2008-05-30 5:45:24
Message-ID: 200805300745.24410.t.zachmann () zagge ! de
[Download RAW message or body]

On Thursday 29 May 2008, Jaroslaw Staniek wrote:
> Thomas Zander said the following, On 2008-05-29 10:11:
> > On Wednesday 28. May 2008 10:49:55 Christian Ehrlicher wrote:
> >> KoPageLayout SheetPrint::paperLayout() const
> >> {
> >>     return m_settings->pageLayout();   // here the pageLayout is copied
> >> }
> >>
> >> void otherFunction()
> >> {
> >>   paperlayout().width = 25;
> >> }
> >
> > The pattern intended (and used in Qt) is that the otherFunction would
> > have to do;
> >   KoPageLayout pl = print.paperLayout();
> >   pl.width = 25;
> >   print.setPaperLayout(pl);
>
> This would suggest that KoPageLayout is implicitly shared for efficiency.
> It is not, instead it contains uninitialized members as optimization.
>
> KoPageLayout (and similar structs) cannot be fully compared to the Qt
> pattern, because the former is designed in a C-like way: (again:
> uninitialized members).
>
> Moreover structs with methods could become classes for clarity.
>
> We fix struct/class warnings every month in KOffice. Looks like a proposal
> for JJ before our API stabilizes, and start using classes everywhere except
> for real C structs.
>
> Thoughts?

A struct is just a class where members are public as default. I would not like 
to change all structs to classes as I really enjoy the possibility to write 
less.

Thorsten


_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

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