comp.lang.ada
 help / color / mirror / Atom feed
From: n_brunot@my-deja.com
Subject: Re: Ok sorry, it is just a book gives no feedback.
Date: Fri, 05 Jan 2001 08:53:06 GMT
Date: 2001-01-05T08:53:06+00:00	[thread overview]
Message-ID: <93421h$2ju$1@nnrp1.deja.com> (raw)
In-Reply-To: 932an8$ijs$1@nnrp1.deja.com

In article <932an8$ijs$1@nnrp1.deja.com>,
  Robert Dewar <robert_dewar@my-deja.com> wrote:
> In article <932632$e0e$1@nnrp1.deja.com>,
>   n_brunot@my-deja.com wrote:
> > Just look the following code (simplified from old buggy code).

> This would be horrible code even if procedures were used.
> Global variables in general are harmful if not very carefully
> used.

Exactly, that's right. :-)
I found this kind of code in several years old code which worked
perfectly well until compiled on a compiler differently evaluating "&".
When you have a big project with more than 1 million lines code, it's
unrealistic to assume that this kind of thing is impossible.
Assuming that one single person, however genius he is, can check every
single line code, and cannot make mistakes is totally unrealistic and
dangerous.

Therefore simple rules like
- yes, avoid side effects when you can
- no, don't avoid them if you cannot :-)
(Is it necessary to say such an evidence ...)
- test your code on different compilers
(you'll have more chances to detect bugs which could remain unnoticed
because of specific behavior of one compiler)

are wise and don't bring any restriction

> You argue that functions should not have side effects.

Yes, when you can avoid it, avoid it :-)
No, nobody said that side effects are forbidden,
look at previous posts ...

> point is that there are plenty of legitimate functions that
> have side effects in the sense in which they were defined
> here.

Yes, nobody denied that, and nobody said it's bad :-)

> E.g. A function that takes two pointers to strings and returns
> a pointer to their concatenation is quite reasonable, but has
> side effects according to this definition.
> Note that ANY allocation has a side effect, so these rules
> about
> functions would say that no functions can ever do allocations.
> That's an unreasonable restriction!

And may be that's we never read anything asking for that !! :-)



Sent via Deja.com
http://www.deja.com/



  reply	other threads:[~2001-01-05  8:53 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-31 14:18 Ok sorry, it is just a book gives no feedback Mark Pagdin
2000-12-31 16:56 ` Robert Dewar
2000-12-31 16:57 ` Robert Dewar
2001-01-01 11:03 ` Tarjei T. Jensen
2001-01-02  9:23 ` Newsgroup cla (was: Ok sorry, it is just a book gives no feedback.) Anders Wirzenius
2001-01-02 10:44   ` Florian Weimer
2001-01-02 13:21     ` Larry Kilgallen
2001-01-02 12:45   ` Andrew Hately
2001-01-02 13:25     ` Florian Weimer
2001-01-02 22:26 ` Ok sorry, it is just a book gives no feedback John English
2001-01-03  6:24 ` Nick Roberts
2001-01-04 13:14   ` Robert Dewar
2001-01-04 15:49     ` n_brunot
2001-01-04 17:09       ` Robert Dewar
2001-01-05  8:53         ` n_brunot [this message]
2001-01-05 13:45           ` Robert Dewar
2001-01-05 21:23             ` Randy Brukardt
2001-01-06  4:05               ` Larry Kilgallen
2001-01-06 17:11                 ` Robert Dewar
2001-01-06 20:26                   ` Larry Kilgallen
2001-01-06 22:40                     ` Robert Dewar
2001-01-07  1:12                       ` Larry Kilgallen
2001-01-07  4:19                         ` Robert Dewar
2001-01-07 17:12                           ` Larry Kilgallen
2001-01-08 12:26                             ` Marin David Condic
2001-01-08 12:57                             ` Larry Kilgallen
2001-01-08 15:01                     ` Stephen Leake
2001-01-08 15:58                       ` Ted Dennison
2001-01-09 21:13                       ` Jean-Pierre Rosen
2001-01-06 19:46               ` Laurent Guerby
2001-01-06 20:36                 ` Robert Dewar
2001-01-07 13:09                   ` Laurent Guerby
2001-01-07 15:56                     ` Robert Dewar
2001-01-07 16:25                       ` Laurent Guerby
2001-01-07 15:58                     ` Robert Dewar
2001-01-07 17:19                     ` Larry Kilgallen
2001-01-06  7:13           ` Simon Wright
2001-01-07 16:00             ` Robert Dewar
2001-01-07 17:16             ` Larry Kilgallen
2001-01-04 17:11       ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox