Date: Mon, 28 Sep 1998 12:48:54 +0300 (IDT) From: Eli Zaretskii To: "John S. Fine" cc: djgpp AT delorie DOT com Subject: Re: Optimizations In-Reply-To: <360ED7DD.46AC@erols.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.