comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada syntax questions
Date: Fri, 18 Dec 2020 10:18:45 +0100	[thread overview]
Message-ID: <rrhs5l$6a0$1@gioia.aioe.org> (raw)
In-Reply-To: 5fdbde31$0$6455$426a74cc@news.free.fr

On 2020-12-17 23:39, DrPi wrote:

> Ada claims to have a better syntax than other languages.
> I'm fine with with, but...
> 
> 1) What about array indexing ?
> In some other languages, arrays are indexed using square brackets. In 
> Ada, parentheses are used for function calls and for array indexing.
> In the code "status := NewStatus(some_var);", you can't tell if 
> NewStatus is a function or an array.
> 
> 2) In Ada, a function without arguments is called without any parentheses.
> In the code "status := NewStatus;", you can't tell if NewStatus is a 
> function or a variable.
> 
> 
> For my knowledge, are there good reasons for these syntaxes ?

1. Separation of interface and implementation. Being array or function 
is an implementation detail of a map or a named entity.

Another example is pointer dereferencing. In Ada X.A is same as P.A. In 
C you have X.A vs P->A.

Yet another one. All instances of parametrisation in Ada deploy () 
parentheses. In C++ it would be <>, [], (), depending on semantically 
irrelevant context.

2. Languages that like C use bottom-up matching are forced to 
distinguish certain things prematurely on the syntax level. This is also 
the reason why you cannot use the result type to distinguish signatures 
in C++, but you can in Ada. Thus in C++ you would have something as 
disgusting as

    123ull

while in Ada it is just

    123

Long time ago anything but strictly bottom-up matching was considered 
too complicated or impossible. So artificial distinctions like () vs [] 
were invented and then promoted into orthodoxy.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  parent reply	other threads:[~2020-12-18  9:18 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17 22:39 Ada syntax questions DrPi
2020-12-17 23:18 ` Gabriele Galeotti
2020-12-18  8:26 ` Jeffrey R. Carter
2020-12-18  9:18 ` Dmitry A. Kazakov [this message]
2020-12-18 16:55 ` Mart van de Wege
2020-12-18 17:38 ` Björn Lundin
2020-12-18 19:35 ` Niklas Holsti
2020-12-20 21:59   ` Keith Thompson
2020-12-22  1:04     ` Randy Brukardt
2020-12-22  8:00       ` Dmitry A. Kazakov
2020-12-23  1:23         ` Randy Brukardt
2020-12-23  8:59           ` Dmitry A. Kazakov
2020-12-24  4:06             ` Randy Brukardt
2020-12-24  9:37               ` Dmitry A. Kazakov
2020-12-22 13:48       ` AdaMagica
2020-12-20 21:59   ` Keith Thompson
2020-12-21  8:08     ` Dmitry A. Kazakov
2020-12-18 23:09 ` Stephen Leake
2020-12-19 11:50   ` DrPi
2020-12-19 12:40     ` Dmitry A. Kazakov
2020-12-19 17:13       ` Andreas ZEURCHER
2020-12-19 17:49         ` Dmitry A. Kazakov
2020-12-19 18:40           ` Andreas ZEURCHER
2020-12-19 19:37             ` Dmitry A. Kazakov
2020-12-19 22:11               ` Andreas ZEURCHER
2020-12-20  8:47                 ` Dmitry A. Kazakov
2020-12-20 16:53                   ` Andreas ZEURCHER
2020-12-22  0:58                     ` Randy Brukardt
2020-12-22  2:39                       ` Andreas ZEURCHER
2020-12-22 10:05                     ` Stéphane Rivière
2020-12-25  9:34                     ` G.B.
2020-12-19 17:01     ` AdaMagica
2020-12-19 21:51     ` Stephen Leake
2020-12-19 22:20       ` Andreas ZEURCHER
2020-12-20 14:10       ` DrPi
replies disabled

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