www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/28/05:48:56

Date: Mon, 28 Sep 1998 12:48:54 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "John S. Fine" <johnfine AT erols DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Optimizations
In-Reply-To: <360ED7DD.46AC@erols.com>
Message-ID: <Pine.SUN.3.91.980928124755.29939O-100000@is>
MIME-Version: 1.0

On Sun, 27 Sep 1998, John S. Fine wrote:

>   Routines that do simple computations (like sin or cosin) have no
> side effects.  Routines that read or write files (or keyboards or
> screens or serial ports etc.) have side effects.  Routines that
> format data into buffers have side effects.  Routines that sort
> arrays have side effects.  Nearly every routine a typical
> program calls has side effects.

The last assertion is too broad to be true.  There's still a lot a
programmer can do to minimize the side effects (if this is at all a
goal of that programmer).  It is true that functions that do I/O have
side effects that can hardly be avoided, but some other examples you
cite can certainly be designed and written in a way that doesn't have
side effects as far as GCC is concerned.  For example, a function that
sorts a buffer can return the sorted buffer as its value, and then it
has no side effect in the context of this discussion (i.e., you can
declare it with a const attribute).

In fact, languages such as Lisp and LOGO actively force you into such
paradigms.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019