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

List:       cfe-dev
Subject:    Re: [cfe-dev] Proposal: A "Const tool" for clang
From:       Marshall Clow <mclow.lists () gmail ! com>
Date:       2013-02-05 17:03:40
Message-ID: D89C0B58-5D29-4900-B9A9-55557CB4FDE5 () gmail ! com
[Download RAW message or body]

On Feb 4, 2013, at 9:58 PM, Dmitri Gribenko <gribozavr@gmail.com> wrote:
> On Tue, Feb 5, 2013 at 2:55 AM, Marshall Clow <mclow.lists@gmail.com> wrote:
> > Broadly speaking, there are three places where const can be added to an existing \
> >                 code base:
> > * Parameters that are passed by reference or pointer can be passed by const \
> >                 pointer or const reference.
> > * object methods can be marked as const
> > * Return values that are returned by pointer or reference can be returned by \
> > const reference or const pointer. This may involve adding an additional function \
> > alongside the original, differing only in the return value.
> 
> Local variables might require adding 'const', too.  A dumb example:
> 
> int f(Z *z) {
> Z *a = z->getA();
> return a->getInt();
> }
> 
> If there's a const and non-const overload of getA() and getInt(), then
> one can actually add const everywhere in this example.

Nice example - thanks!

-- Marshall

Marshall Clow     Idio Software   <mailto:mclow.lists@gmail.com>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly \
                moderated down to (-1, Flamebait).
        -- Yu Suzuki


_______________________________________________
cfe-dev mailing list
cfe-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


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

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