comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Overloading parentheses and type expectations
Date: Fri, 02 Sep 2011 12:37:17 +0200
Date: 2011-09-02T12:37:17+02:00	[thread overview]
Message-ID: <4e60b1dd$0$6635$9b4e6d93@newsspool2.arcor-online.net> (raw)
In-Reply-To: <l2yxnfjk1lez.38x8jcf4biug$.dlg@40tude.net>

On 02.09.11 09:54, Dmitry A. Kazakov wrote:

> Rubbish, mathematical notation is taught in school. It is easy to show that
> all known alternatives (e.g. Polish expressions) are incomprehensive for
> normal people.

Still, I hesitate to call empirical findings "rubbish".

Mathematical notation may, and does, use a circled ⊕,
not + when the writer wants to emphasize that she isn't
referring to some "known" +. Also, dot minus, ∸, is
sometimes used for subtraction never going below 0.
The use of ∫ is common for indicating an integral. TTBOMK,
the symbol isn't used to denote anything but integrals.
Unlike the way () has many uses in Ada.  And ∫ is not
used in Ada (or similar languages), but + is. Why?

Is there anything about + that makes its meaning more special
than that of ∫? More worthy of being included in the language?
Is + better adjusted to how our brain works than ∫ and that
therefore is a privileged symbol?

Or is it habit + keyboard?  I guess it is.  No need to refer
to cognitive psychology.

When computers had less characters for syntax, and programmers
typed <<< x : x in S .ST. P(x) >>> or similar instead of
{x : x in S | P(x)}, they quickly gave up overloaded < etc
when {} and | became available.
Why?  Because (a) they are easier to type, (b) they were
expected in the first place.  There is sanity in finding
a break even point between time spent deciphering
ASCII symbolism at one extreme and symbolitis at the other.

>> Why would a designer want entirely different things in a language
>> and then use the same notation for all of them?
>
> See above. This is the way human brain works. And the things are not
> entirely different, they are instances of some class. The language captures
> this by using "+" everywhere "addition" is meant.

In order to capture meaning of classes, one first has to learn and
become aware and become familiar with what a class is before even
touching and understanding of class. Those not familiar with CS
abstractions, maybe even those who are familiar with CS abstractions,
have not found it obvious that a pointer dereference written p()
is the same thing as an array indexing operation written a(),
or as a function call written f().  Cute as it may seem, common
as it may seem, conceptually sound as it may seem, expressing
differences using .all, [], or () seems to help programmers
understand programs.

And then you would have to go the other way, too, from the common
aspect and the identical syntax for different thingswhen debugging
and trying to determine what kind of () is causing trouble.

Proof:  The lengthy and recurring discussion of a[i] being
the same as *(a + i) in C does not take place when explaining
Ada arrays; but Ada programmers will need to do some
overload resolution work when seeing x(y).

>> First, infix expressions are a (dis)service offered to programmers
>> whose wish is less to program a computer,
>
> I'd like to see a hard proof that, for instance, Forth is more productive,
> safer, easier to understand, etc than Ada.

(Von Neumann called early Fortran notation a waste...)
OK, I'm assuming people insist that infix is really a must;
Although ... only with elementary math operators... Oh, and
with logical operators.

One ingredient of productive programming is the principle
of least surprise.  Overflow is one of the surprises.

: 1 Max_Int + N - ;

(- (+ 1 Max_Int) N)

1 + Max_Int - N;

(1 + Max_Int) - N;

Presuming familiarity with either language, why would the human
brain be better at detecting the error on line 3 and not on
lines 1,2,4? Even though, if I understand correctly, the brain
isn't aided by distinct syntax when breaking things down?

Note that the parens above have only one meaning.

>  Whether "+" is used as an
> infix operation or as a function call, its semantics remains exactly the
> same.

The phrase "its semantics" is stipulating a specific interpretation
of binary "+"; Smalltalk is assigning different meaning to "+",
at least using very different reasoning (to the untrained).
But you do write x + y ...
Meaning is also unclear when languages have rules (or not)
explaining the order of evaluation of arguments; or the effects
of aliasing in the presence of optimization.  I'm saying this not
because Ada didn't care, it does, but because nothing of all
this is visible to the reader studying the expression, infix or not.

The human brain needs to learn, and then to rummage through a mountain
of, information about the expression and its meaning in order to see,
for example, from where this strange and irregularly occurring difference
in executing x + y should stem, for seemingly the same x and y, by the
looks of it.  (Timing dependent shared variable update through y, say.)

> Information unnecessary to understanding the program is noise. When also
> required by the compiler, it constitutes a language deficiency. (There
> could be some exceptions from this rule)

Understanding is on a scale.  This is why we say "easily understood".
This is why I say that I do not want to be forced into being an
inference machine without need. Just to understand something that is totally
obvious and consistent with some little additions I'm fine with, yes,
even redundancies.  And redundancy is subjective, of course.



  reply	other threads:[~2011-09-02 10:37 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-29 15:46 Address and bit mask milouz
2011-08-29 16:06 ` Martin
2011-08-29 16:33   ` milouz
2011-08-29 17:47     ` Dmitry A. Kazakov
2011-08-29 17:54     ` Martin
2011-08-29 18:46     ` tmoran
2011-08-29 19:41 ` Ludovic Brenta
2011-08-29 19:54   ` Adam Beneschan
2011-08-30  9:14     ` milouz
2011-08-30 10:34       ` Ludovic Brenta
2011-08-30 10:58         ` Ludovic Brenta
2011-08-30 12:44           ` Georg Bauhaus
2011-08-30 14:04             ` Dmitry A. Kazakov
2011-08-30 16:12               ` Georg Bauhaus
2011-08-30 16:59                 ` Dmitry A. Kazakov
2011-08-30 14:52         ` Adam Beneschan
2011-08-30 10:40       ` Simon Wright
2011-08-30 10:44         ` Simon Wright
2011-08-30 15:20         ` tmoran
2011-08-30 16:08           ` milouz
2011-08-30 16:45             ` Georg Bauhaus
2011-08-30 19:31               ` Adam Beneschan
2011-08-30 19:56                 ` Dmitry A. Kazakov
2011-08-31  6:16                   ` The simple Image issue (was: Address and bit mask) Georg Bauhaus
2011-08-31 14:44                     ` The simple Image issue Dmitry A. Kazakov
2011-08-31 15:36                       ` Georg Bauhaus
2011-08-31 15:53                         ` Dmitry A. Kazakov
2011-08-31 16:23                           ` Georg Bauhaus
2011-08-31 16:27                             ` Dmitry A. Kazakov
2011-08-31 16:30                               ` Georg Bauhaus
2011-08-31 16:50                                 ` Dmitry A. Kazakov
2011-08-31 20:41                                   ` Georg Bauhaus
2011-08-31 21:17                                     ` Robert A Duff
2011-09-01  7:36                                       ` Dmitry A. Kazakov
2011-09-01  7:46                                     ` Dmitry A. Kazakov
2011-09-01  9:50                                       ` Overloading parentheses and type expectations (was: The simple Image issue) Georg Bauhaus
2011-09-02  7:54                                         ` Overloading parentheses and type expectations Dmitry A. Kazakov
2011-09-02 10:37                                           ` Georg Bauhaus [this message]
2011-09-02 12:40                                             ` Dmitry A. Kazakov
2011-09-02 16:08                                               ` Georg Bauhaus
2011-09-02 17:29                                                 ` Dmitry A. Kazakov
2011-08-31 15:53                     ` The simple Image issue Hyman Rosen
2011-08-31 16:07                       ` Dmitry A. Kazakov
2011-08-31 16:08                       ` Simon Wright
2011-08-31 16:26                         ` Dmitry A. Kazakov
2011-08-31 16:25                       ` Georg Bauhaus
2011-08-31 16:30                         ` Hyman Rosen
2011-08-31 16:34                           ` Georg Bauhaus
2011-08-31 16:43                             ` Adam Beneschan
2011-08-31 21:58                               ` Georg Bauhaus
2011-09-01  7:59                                 ` Dmitry A. Kazakov
2011-08-31 16:08                     ` The simple Image issue (was: Address and bit mask) Adam Beneschan
2011-08-31 16:53                       ` The simple Image issue Simon Wright
2011-08-31 17:02                         ` Hyman Rosen
2011-08-31 20:33                       ` Georg Bauhaus
2011-08-30 19:37             ` Address and bit mask Martin
2011-08-30 16:32           ` Simon Wright
2011-08-31  7:55             ` Ludovic Brenta
2011-08-30 12:35       ` Georg Bauhaus
2011-08-30 13:03       ` Georg Bauhaus
2011-08-30 15:14       ` Adam Beneschan
2011-08-30 15:59         ` Adam Beneschan
2011-08-31  7:45         ` milouz
2011-08-31  8:35           ` Ludovic Brenta
replies disabled

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