comp.lang.ada
 help / color / mirror / Atom feed
From: jgv@swl.msd.ray.com (John Volan)
Subject: Re: An observation of Ada (may offend)
Date: 23 Mar 1995 18:23:14 -0500
Date: 1995-03-23T18:23:14-05:00	[thread overview]
Message-ID: <3ksvt2$299@swlrdv.msd.ray.com> (raw)
In-Reply-To: 3kpkg9$88m@soleil.uvsq.fr

hebert@prism.uvsq.fr (Renaud HEBERT) writes:

>In article <3kbkm1$41o@miranda.gmrc.gecm.com>, bill@valiant.gmrc.gecm.com (R.A.L Williams) writes:
>|> e. No short cut operators (+= etc.) -- sorry, we've had this debate
>|> already in another thread, I've heard the objections, I still like the
>|> operators.

>Could someone summarize the objections against short cut operators, because
>I think that they are great and I 'm quite surprise that they don't exist in
>Ada. No need to start a flamewar, I suppose that as with many construct there
>are pros and cons. It's just that I can't see why those operators could be bad.

There's nothing wrong with the notion of short-cut arithmetic
*procedures*.  It's the idea of short-cut arithmetic *operators* that's
the problem.  

I think it would be quite nice if Ada included some built-in
procedures that provided short-cut arithmetic.  Perhaps these could be
in the form of attributes: For every numeric type T, we'd have
attribute procedures such as:

  procedure T'Increment (What : in out T);            -- analogous to ++ in C
  procedure T'Decrement (What : in out T);            -- analogous to -- in C
  procedure T'Increment (What : in out T; By : in T); -- analogous to += in C
  procedure T'Decrement (What : in out T; By : in T); -- analogous to -= in C
  procedure T'Multiply  (What : in out T; By : in T); -- analogous to *= in C
  procedure T'Divide    (What : in out T; By : in T); -- analogous to /= in C

Barring that, it wouldn't be too hard to "roll your own" solution by
writing reusable generic templates for these subprograms.

But to make these into *operators* would entail some difficulties for Ada:

(1) Operators (at least in Ada terms) are functions; they are
subprograms that return a result.  But the point to these short-cut
arithmetic routines is to cause a side-effect on one of their
parameters.  Having a function that causes a side-effect is somewhat
against Ada's design "philosophy".

(2) IMHO, the whole notion of a return value from this kind of
subprogram is totally extraneous anyway.  The whole point of such a
subprogram is, after all, to cause that side-effect, so the idea of an
incidental return value just adds an unnecessary complication.
Witness the contortions C++ gets into due to the subtle difference
between pre-increment ( ++x ), which returns the value of x *after*
incrementing it, versus post-increment ( x++ ), which returns the value of
x *before* incrementing it.

(In fact, this leads me to pose a question: What is the value of C++?
Does it really provide an *improvement* on C, or does it just yield the
*same* *result*?  Maybe they should have called it ++C instead!!!)
:-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-)

(3) Operators are special symbols, with special syntax (infix, prefix,
postfix), and special semantics (precedence levels).  The syntax and
semantics of the operators we all learned in grade school ( + - * / )
were hard enough to master.  Why gratuitously invent new ones, when you
can do the same job using ordinary subprogram syntax and semantics?
(See my proposed attribute procedures above.)  The only benefit of
short-hand operator symbols is that they make it more convenient for
someone to *write* code -- at the cost of *readability*.  The
philosophy behind the design of Ada was to optimize for readability,
even at the expense of writability, on the assumption that more time
will be spent trying to read and understand Ada code than to write it.

				-- John Volan

--------------------------------------------------------------------------------
 Me : Person :=
   (Name => "John G. Volan",  E_Mail_Address => "jgv@swl.msd.ray.com",
    Employer => "Raytheon",   Affiliation => "Enthusiastic member of Team-Ada!",
    Favorite_Slogan => "Ada95: The World's *FIRST* International-Standard OOPL",
    Humorous_Language_Lawyerly_Disclaimer =>
      "These opinions are undefined by my employer, so using them would be "  &
      "totally erroneous ... or would that be a bounded error? :-) ");
--------------------------------------------------------------------------------






  reply	other threads:[~1995-03-23 23:23 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-17  9:27 An observation of Ada (may offend) R.A.L Williams
1995-03-17 15:23 ` Robb Nebbe
1995-03-17 17:08 ` Norman H. Cohen
1995-03-20  3:23   ` S. Tucker Taft
1995-03-20 10:13   ` Robb Nebbe
1995-03-21 21:05     ` Robert Dewar
1995-03-20 16:15   ` Robert I. Eachus
1995-03-21 19:47     ` Norman H. Cohen
1995-03-22  1:28       ` David Weller
1995-03-23  5:47       ` Robert Dewar
1995-03-23 16:38         ` Robert I. Eachus
1995-03-24 10:46           ` Peter Hermann
1995-03-24 16:52             ` David Weller
1995-03-26  4:03               ` Robert Dewar
1995-03-24 21:33             ` Tucker Taft
1995-03-27  9:59             ` Child packages Robb Nebbe
1995-03-28  1:11               ` Keith Thompson
1995-03-28 11:54                 ` Keith Thompson
1995-03-27 18:58             ` An observation of Ada (may offend) Mark A Biggar
1995-03-24 19:45           ` Garlington KE
1995-03-27 19:58             ` Robert I. Eachus
1995-03-28 16:29               ` Garlington KE
1995-03-28 19:30                 ` Robert I. Eachus
1995-03-28 22:37                   ` Garlington KE
1995-03-29  8:31                   ` Robb Nebbe
1995-03-25 17:58           ` Robert Dewar
1995-03-26  6:20             ` R_Tim_Coslet
1995-03-27 20:38               ` Robert I. Eachus
1995-03-26  3:50           ` celier
     [not found]           ` <3l1lkq$pm6@gnat.csn <3l2o9a$3a1@infomatch.com>
1995-03-27 23:16             ` Robert Dewar
1995-03-23 18:05       ` John DiCamillo
1995-03-17 23:01 ` Larry Kilgallen, LJK Software
1995-03-18 12:41 ` Tucker Taft
1995-03-22 16:50 ` Renaud HEBERT
1995-03-23 23:23   ` John Volan [this message]
1995-03-24  0:38   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1995-03-30  0:00 R.A.L Williams
1995-04-03  0:00 ` Norman H. Cohen
1995-03-29  0:00 R.A.L Williams
1995-03-27 10:38 R.A.L Williams
1995-03-30  3:14 ` Michael D. Griffin
1995-03-30  0:00   ` David Weller
1995-04-04  0:00   ` Jack Beidler
1995-04-04  0:00   ` Brian Rogoff
1995-03-27 10:28 R.A.L Williams
1995-03-27  0:00 ` Norman H. Cohen
1995-04-04  0:00   ` Robert Dewar
1995-03-28 17:07 ` Larry Kilgallen, LJK Software
1995-03-12 23:39 Matt Bruce
1995-03-13  0:34 ` David Weller
1995-03-14  4:49 ` Vladimir Vukicevic
1995-03-17 17:00   ` Michael Feldman
1995-03-17 13:09     ` Fred J. McCall
1995-03-18 20:34       ` Michael Feldman
1995-03-19 22:20         ` Robert Dewar
1995-03-20 17:19           ` Michael Feldman
1995-03-21 21:02             ` Robert Dewar
1995-03-21 23:01             ` Kevin F. Quinn
1995-03-22 12:43             ` Mike Meier
1995-03-20 20:38           ` Kevin F. Quinn
1995-03-21  3:02         ` Michael M. Bishop
1995-03-20  9:31       ` Robb Nebbe
1995-03-20 20:16       ` Mats Weber
1995-03-22 19:44       ` Stephen McNeill
1995-03-28 14:48       ` Wes Groleau
1995-03-22 17:20     ` Richard G. Hash
replies disabled

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