Re: A couple items on TODO

From: Ian Lance Taylor <ian(at)airs(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>, "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Jeff Davis" <list-pgsql-hackers(at)dynworks(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: A couple items on TODO
Date: 2001-08-24 22:11:48
Message-ID: siae0prtuj.fsf@daffy.airs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au> writes:
> > I have noticed while working on command.c and heap.c that half the functions
> > pass 'const char *' and the other half pass just 'char *'. This is a pain
>
> Yeah, people have started to use 'const' in new code, but the older
> stuff doesn't use it, which means that the net effect is probably
> more annoyance than help. I'm afraid that if we attack this in an
> incremental way, we'll end up with code that may have a lot of const
> markers in the declarations, but the actual code is riddled with
> explicit casts to remove const because at one time or another that
> was necessary in a particular place.
>
> Can anyone think of a way to get from here to there without either
> a lot of leftover cruft, or a "big bang" massive changeover?

You don't need a flag day, if that's what you mean. You just start
adding const at the lowest levels and grow them upwards. I've done it
before in large old projects. It's easy to do a few functions as a
fairly mindless task. You get there eventually. The main trick is to
never add casts merely to avoid warnings (they will never get removed
and are a potential source of future bugs), and to make sure that new
functions use const wherever possible (so you don't move backward over
time).

It's worth it in the long run because it gives another way to catch
stupid bugs at compile time.

Ian

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ian Lance Taylor 2001-08-24 22:22:47 Re: List response time...
Previous Message Rene Pijlman 2001-08-24 22:02:02 Re: JDBC changes for 7.2... some questions...