[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: const-ness

From: Greg Stein <gstein_at_lyra.org>
Date: 2000-12-16 07:27:08 CET

On Sat, Dec 16, 2000 at 07:07:31AM +0100, Branko Cibej wrote:
> Greg Stein wrote:
> > Mostly, the only change is when lists are constructed. Currently, this is
> > typically done by creating and empty list, followed by a set of prepend
> > calls. I could see a variadic function to create a list from the N args.
> > I'm thinking something like:
> >
> > list = make_list(pool, "ssSm", cstr1, cstr2, svnstr1, ptr, len);
>
> No no no no! I'm shocked that you're talking about adding "const" for
> safety reasons and variadic functions in the same breath.

Heh. :-)

The problems aren't very similar. The "const" problem is to prevent coupling
across a broad set of functions/modules. A variadic function does not
introduce the same kind of coupling, so there is a *much* smaller chance for
unintended side effects.

Yes, it is possible to pass incorrect params to a format-string-based
variadic, but you'll probably see them the first time you hit that line of
code. Once that line is correct, it is very difficult to break it.

Dropping "const" from a system opens up holes for problems. The code is
"looser", if you will, and is less robust. Change some in X, and an
assumption that Y made about "well, it won't change it" could be blown away.

> > [ and yes: if I suggest it, then I'm also signing up to write it if need be ]
>
> Ah, then you're also signing up to debug all wrong usage that'll crop
> up. That's fine then, go ahead. :-)

For this? Sure. I doubt we'll see problems with this code pattern.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/
Received on Sat Oct 21 14:36:17 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.