comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm-host.bauhaus@maps.futureapps.de>
Subject: Re: Gnat GPL 2010 available soon (conditional expressions)
Date: Sun, 27 Jun 2010 10:04:35 +0200
Date: 2010-06-27T10:04:35+02:00	[thread overview]
Message-ID: <4c270613$0$6974$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <1frrgtpa5dycl$.12kl72iqsg3dx$.dlg@40tude.net>

On 6/26/10 11:42 PM, Dmitry A. Kazakov wrote:
> On Sat, 26 Jun 2010 05:04:10 -0700 (PDT), lekktu@gmail.com wrote:
>
>> Well, it hasn't been hard to find the first bug.
>>
>> --------------------------------------------------------------------------------
>> function Validate (Dir : in String) return String is
>> begin
>>     return (if Dir (Dir'Last) = '\' then Dir else Dir&  '\');
>> end Validate;
>> --------------------------------------------------------------------------------
>
> [...]
>> I'll submit a bug report.
>
> (Yes, to remove that abomination from the language! (:-))
>
> I didn't read the AI, but your code looks very strange to me. Isn't its
> syntax exposed to the infamous Pascal-if flaw? I mean, where is the "end
> if"? Is this legal:
>
>     (if A then X else if B then Y else Z)

As the AI explains, you will need bracketing.

WRT syntax, the Validate above example is OK for GNAT 2009
with -gnatX, but this GNAT wants constraints on the return value.

And, yes, one may omit the "else branch" in a conditional expression
if the result should be Boolean, thus implying True...

Conditional expressions are supposed to remove the need for some single
purpose functions, see the example in the AI lekktu has mentioned.
   Unlike the return object of a function, the value of a
conditional expression cannot be renamed.  A special purpose
function in place of a conditional expression has to have a
return object. We can't rely on effective inlining or on
evaluation at compile time, either. If so, then in principle
there is overhead.  This is solved with conditional expressions.

OTOH, we get the anonymity of conditional expressions, and
an opportunity to deviate from Ada's principle of linear reading.

But maybe the principle of linear has become outdated?

John Barnes's integration example forces the reader
up and down the nesting structure when reading, as do
some container algorithms.  And they make sense!
So maybe conditional expressions deserve the same
exception from a preference for linear reading?

Consequently, conditional expressions will make Ada
more attractive for programmers who still know the joys of
clever programming constructs like syntactical inversion
of control structure. Or who have been brought up with Lisp
or Caml.  If their modes of expression are not wanted on some project,
the project can use additional source code analysis tools.
These will complain when noticing nested conditional expressions,
for example.




  parent reply	other threads:[~2010-06-27  8:04 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-16 20:14 Gnat GPL 2010 available soon Stephen Sangwine
2010-06-16 21:24 ` Martin
2010-06-16 21:35 ` Simon Wright
2010-06-18 19:48 ` Albrecht Käfer
2010-06-26 12:04   ` lekktu
2010-06-26 21:04     ` anon
2010-06-26 21:41       ` lekktu
2010-06-27  3:33         ` anon
2010-06-27 10:49           ` lekktu
2010-06-26 21:42     ` Dmitry A. Kazakov
2010-06-26 22:01       ` lekktu
2010-06-27  8:04       ` Georg Bauhaus [this message]
2010-06-27  8:37         ` Gnat GPL 2010 available soon (conditional expressions) Dmitry A. Kazakov
2010-06-27 10:55           ` lekktu
2010-06-27 12:12             ` Dmitry A. Kazakov
2010-06-27 13:42               ` Georg Bauhaus
2010-06-27 14:35                 ` Peter C. Chapin
2010-06-27 16:53                   ` Dmitry A. Kazakov
2010-06-28 11:24                     ` Peter C. Chapin
     [not found]                       ` <oizwym2afwmx.1jm5tt7wtpm7v.dlg@40tude.net>
2010-06-28 14:47                         ` Georg Bauhaus
2010-06-28 16:36                           ` Dmitry A. Kazakov
2010-06-28 17:04                             ` Georg Bauhaus
2010-06-28 17:37                               ` Dmitry A. Kazakov
2010-06-29 19:28                   ` Randy Brukardt
2010-06-30  1:19                     ` BrianG
2010-06-30  3:21                       ` Britt Snodgrass
2010-07-05  1:27                         ` Phil Clayton
2010-07-05 10:26                           ` Georg Bauhaus
2010-07-05 14:24                             ` Phil Clayton
2010-07-05 13:12                           ` Dmitry A. Kazakov
2010-07-05 22:47                             ` Phil Clayton
2010-07-06  7:36                               ` Dmitry A. Kazakov
2010-07-06  9:13                                 ` Georg Bauhaus
2010-07-06 16:31                                 ` Phil Clayton
2010-07-06 17:18                                   ` Dmitry A. Kazakov
2010-07-07 12:00                                     ` Phil Clayton
2010-07-07 13:39                                       ` Dmitry A. Kazakov
2010-06-30  4:13                       ` Gautier write-only
2010-06-30 16:46                         ` Warren
2010-06-30  4:09                     ` Gautier write-only
2010-06-30 23:20                       ` Peter C. Chapin
2010-06-27 21:40 ` Gnat GPL 2010 available soon mahdert
replies disabled

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