bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnulib-tool.py: Omit some unnecessary list() calls around sorted().


From: Bruno Haible
Subject: Re: gnulib-tool.py: Omit some unnecessary list() calls around sorted().
Date: Mon, 08 Apr 2024 20:48:40 +0200

Hi Collin,

> Here is two janitorial work patches.

Thanks, applied.

> I remember an extra dict() call causing trouble with GLMakefileTable.
> Removing the extra list() calls from sorted() seemed like a good place
> to start cleaning up.

Well, that extra dict() call made trouble because in that particular case,
a side effect was desired. Usually, side effects are not desired and,
if they occur, lead to bugs that are long to debug. That was the motivation
for Dmitry's many list() and dict() calls. But now that we have a test suite,
we can drop this extra precaution.

The general rule (in most software projects) is: Do not make side effects on
the values returned by other functions. Make side effects only
  - on local variables,
  - on returned values, if that is intentional.

Things are different for example in libraries that are meant to be used by
other software developers. Since you cannot assume that these developers will
always follow this rule without making mistakes, the common approach there
is that functions return a copy of the internal data, so that side effects
will not have effects that look like library bugs.

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]