comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Overloading parentheses and type expectations (was: The simple Image issue)
Date: Thu, 01 Sep 2011 11:50:59 +0200
Date: 2011-09-01T11:51:00+02:00	[thread overview]
Message-ID: <4e5f5583$0$6623$9b4e6d93@newsspool2.arcor-online.net> (raw)
In-Reply-To: <85cspp5yd1u1$.krrkdtgmlj4j.dlg@40tude.net>

On 01.09.11 09:46, Dmitry A. Kazakov wrote:
> On Wed, 31 Aug 2011 22:41:01 +0200, Georg Bauhaus wrote:
>
>> Still SPARK, and in some more cases Ada, do require that we write
>> T'() anyway: to resolve another ambiguity (of ()).
>
> Fix SPARK!

Not. At least if this makes me an inference machine for "()";
a "disambiguator"; or a de-obfuscator of clever abbreviations,
omitted names, and long lists of positional parameters.

What is the use of clever detection?  To show that in

   f(1),

given function f, the 1 can only be a an array of length 1?
This, to me, is obfuscation.

> There is no usable languages without overloading. Since you mentioned ()
> [meaning aggregates], think about them used for ordering:
>
>     (x)
>
> returns what? For each type and subtype of x there is some "()". They all
> are overloaded. Do you wish to annotate each of them?


There is evidence that overloading the meaning of () is not
working with normal people, e.g. McIver & Conway (1996). They arent't
aguing about advanced programmers, though. The Turing language has made
() a kind of universal "pick from" operator, arrays, dereferencing,
taking part-of, ..., besides the usual uses.  Readers
will need to disambiguate uses of "()" if they want to know what
some expression actually does.  Some programmers want to know
what an expression does. Other programmers must know what
an expression does.  M & C found that Turing made it difficult
to learn the differences between things all written using "()".

Why would a designer want entirely different things in a language
and then use the same notation for all of them?  Given the evidence,
I think the disadvantages outweigh the advantages.

>     I := Integer'(1 + 2) * 4 ?

Qualification, association, and infix operators.

First, infix expressions are a (dis)service offered to programmers
whose wish is less to program a computer, but rather to write
executable formal expressions (such as non-CS formulas)
in blissful ignorance of the computer. (Even when they like
HP calculators...)  Infix doesn't work well unless
the subject is more or less mathematical and when work can ignore
TIME and SPACE.

I cannot say it better than,
http://c2.com/cgi/wiki?OperatorPrecedenceConsideredHarmful

Then, infix is complex to understand when the model is otherwise that
of simple object oriented programming (ignoring inheritance).
In 3 + 5 (or x + y), which object does "+" manipulate?
Or will the execution update the "+" object?  Consider

   a := 1;
   a.add(2);
   if a /= 3 then
      raise Program_Error;
   end if;

This would put me in a different mode of thinking, and of understanding.
There are no operational effects (or surprises!) of association and
precedence.


Third, an occurrence of qualifying T'(...) frequently creates an object.
When the object appears alone, as in a typical initialization expression,
repeating the type's name may seem silly and redundant.  Just for context,
some less specific circumstances.

   declare
      X : T0'class := T3'( ... );
   begin

is different from

   declare
      X : T3 := ( ... );
   begin

and different from

    Integer'(1 + 2) * 4


"Qualifying" in a different way, though much like Integer'(1 + 2) is not
without uses:

    for P in Pins range 1 .. 3 loop

rather than

    for P in 1 .. 3 loop

carries more information, and will add information that is sometimes
necessary for the Ada compiler to know the literals and their types.
I don't find them necessarily silly and redundant.  Strict, yes.


> Since the dictionary of any language is far less than the number of
> entities an average program in that language describes, you simply cannot
> avoid some kinds overloading.

Sometimes overriding works better than overloading.

At the level of overloading ASCII punctuation, I think the less,
the better.  Use symbols only for things heavily loaded with
meaning. The art is in finding the right weight.




  reply	other threads:[~2011-09-01  9:50 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                                       ` Georg Bauhaus [this message]
2011-09-02  7:54                                         ` Overloading parentheses and type expectations Dmitry A. Kazakov
2011-09-02 10:37                                           ` Georg Bauhaus
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