🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Jean-Louis Moser Fri, 20 Oct 1995 16:40
Q: why not a Side effect qualifier ?
#2268
Author: Jean-Louis Moser
Date: Fri, 20 Oct 1995 16:40
52 lines
2131 bytes

On october 13, I asked:

|   is A a = 100; equivalent to A a (100); ?

If I well understand the different threads the answer is NO.

   A a = 100 is known as copy initialization and may or not require
   Copy constructor depending on compilers optimizations which can be
   different from a compiler to an other, but without taking in account
   copy constructor side effect.
   
Why C++ methods an functions could not be qualified as having "SideEffect".
This could enable compilers to make more and predictable optimizations.
Suppose this stupid code:

|   #include "A.h"
|   A a;
|   int x = a.val() + a.val();

If this code doesn't know A::val implementation, that is, A interface is
in A.h and A implementation in A.cc, A::val() will be called twice even
A::val() is a const method, because compiler can not see the implementation
of A::val() which can be:

	{return 1;} (no side effect)
or
	{return global_var++;}

The Side Effect property would be inherited by any function or method
which would have in its body a Side Effect function or method. global
or static variable affect, I/O would be Side Effect functions.

what about this ?

jlm

   

   
--
+----------------------------+------------------------------------+
|   Jean-Louis Moser         |    2001 SA                         |
|   tel: 33 (1)46.66.54.54   |    2, rue de la renaissance        |
|   Email: jlm@two-oo-one.fr |    F-92184 Antony Cedex            |
+----------------------------+------------------------------------+

---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads