comp.lang.ada
 help / color / mirror / Atom feed
From: martijn@and.nl (Martijn Bak)
Subject: Ada vs. C
Date: Mon, 30 Jan 1995 15:33:19 GMT
Date: 1995-01-30T15:33:19+00:00	[thread overview]
Message-ID: <D385vK.GGq@and.nl> (raw)
In-Reply-To: 3g655n$q5k@theopolis.orl.mmc.com

>It all falls out of the design of the language. Constructs like "+="
>provide no benifit other than to save typing within a single
>statement. Take the statement:
>
>  Principle = Principle + (Interest * Time)
>
>The "+=" operator is MADE for this statement, but its ONLY benifit is
>to save me 11 characters in my source file. 

Nope, in general this is _not_ true! The statements
	expr1 += expr2;
and
	expr1 = expr1 + expr2;
are _not_ the same. In the former, expr1 is evaluated only once, in the
latter expr1 is evaluated twice. This is not only a matter of execution
speed. It is especially important if expr1 has side-effects.

There is also a conceptual benefit for the += (if expr1 is very complex).
Compare
	a[i->j(q,b)] = a[i->j(q,b)] + 2;
and
	a[i->j(q,b)] += 2;

In the latter case, neither the writer nor the reader of this code need
to check whether a[i->j(q,b)] and a[i->j(q,b)] realy are the same.

Yep, I _am_ a C programmer.

-- 
-- Martijn Bak -- AND Software -- Westersingel 108, 3015 LD  Rotterdam --
-- tel: +31-10-4367100 -- fax: +31-10-4367110 -- email: martijn@and.nl --



  parent reply	other threads:[~1995-01-30 15:33 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3etund$hnr@miranda.gmrc.gecm.com>
1995-01-12  9:56 ` "Subtract C, add Ada" Erik Svensson
     [not found] ` <3f0n6b$qnp@theopolis.orl.mmc.com>
     [not found]   ` <3f3cq3$4tu@gnat.cs.nyu.edu>
1995-01-12 14:25     ` uninitialzed variables Richard Kenner
1995-01-12 14:44 ` "Subtract C, add Ada" Norman H. Cohen
1995-01-13  1:51 ` David O'Brien
1995-01-13 12:38   ` Laurent Gasser
1995-01-13 20:53     ` John DiCamillo
     [not found]       ` <3f8fnf$c8p@gamma.ois.com>
1995-01-16 11:02         ` Matt Kennel
     [not found]         ` <milodD2IFpG.329@netcom.com>
1995-01-17 21:39           ` R. William Beckwith
     [not found]       ` <3fa11q$sdh@gnat.cs.nyu.edu>
1995-01-16 20:20         ` David Moore
1995-01-14  0:24     ` David O'Brien
1995-01-20  4:43     ` Samuel Mize
1995-01-21 20:28       ` David O'Brien
1995-01-22 21:12         ` Robert Dewar
1995-01-23 18:35         ` Norman H. Cohen
1995-01-23 19:18         ` John Cosby - The Coz
1995-01-24 14:11         ` Samuel Mize
     [not found]         ` <3g655n$q5k@theopolis.orl.mmc.com>
1995-01-30 15:33           ` Martijn Bak [this message]
1995-01-14 10:37   ` Keith Thompson
     [not found]     ` <3fcjgt$b0v@cronkite.seas.gwu.edu>
1995-01-16 18:47       ` Robert Dewar
     [not found]   ` <D2It0r.4rp@inmet.camb.inmet.com>
1995-01-17 14:11     ` Norman H. Cohen
     [not found]   ` <3g9nir$fpl@gnat.cs.nyu.edu>
1995-01-28 20:23     ` Increment operator (+=) Jacob Sparre Andersen
     [not found]     ` <3gc5be$frj@Starbase.NeoSoft.COM>
1995-01-29 12:51       ` Adding in COBOL Robert Dewar
1996-08-07  0:00 Ada vs. C The Quelisher
1996-08-09  0:00 ` Robert Dewar
1996-08-09  0:00   ` The Quelisher
1996-08-10  0:00     ` Robert Dewar
1996-08-10  0:00     ` Bob Kitzberger
1996-08-10  0:00     ` steved
1996-08-10  0:00       ` Robert Dewar
1996-08-11  0:00     ` Jerry van Dijk
1996-08-11  0:00     ` Dave Wood
1996-08-14  0:00       ` busigin
1996-08-16  0:00         ` Robert Dewar
1996-08-12  0:00   ` Vladimir Vukicevic
1996-08-09  0:00 ` Jack W Scheible
1996-08-09  0:00 ` Daniel P Hudson
1996-08-09  0:00   ` 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