comp.lang.ada
 help / color / mirror / Atom feed
From: "Peter C. Chapin" <pcc482719@gmail.com>
Subject: Re: Gnat GPL 2010 available soon (conditional expressions)
Date: Sun, 27 Jun 2010 10:35:02 -0400
Date: 2010-06-27T10:35:02-04:00	[thread overview]
Message-ID: <4c276114$0$2378$4d3efbfe@news.sover.net> (raw)
In-Reply-To: <4c275562$0$6987$9b4e6d93@newsspool4.arcor-online.net>

On 2010-06-27 09:42, Georg Bauhaus wrote:

> Python has your syntax, too, though it didn't from the start,
> see about PEP 308, where Kuchling writes, "so the order of
> evaluation jumps around a bit": The expression
> 
>   B if A else C
> 
> places the controlling expression in the middle of
> what it is controlling.  This placement seem obvious when
> painting program trees but we are writing programs on single
> lines. When you read linearly, IF will signal that some
> case distinction is coming.  When IF appears after what
> it is controlling, you are reminded that what you have
> just been reading is actually conditional on some program
> text to follow next.  And maybe there is going to be some
> other thing for the other case. Or maybe not.

For what it's worth, I agree that the syntax with the leading 'if' is
much more readable to me than the alternatives presented here so far.
For one thing (if A then B else C) seems pretty widely used by
functional languages (OCaml, Haskell, Scala, even Lisp after accounting
for Lisp's general syntax). It also reads well in English, which is true
of other Ada constructs.

In any case I want to know up front that what I'm about to read is
conditional. If I have to first read over some (potentially complex)
expression before I come to the syntax that signals the conditionality
of the construct, I will end up back tracking and reading the expression
again.

Also I find that when skimming program text just knowing that something
is conditional is sometimes enough for me to decide if I have to read it
more closely or not. If it says

X := (if Rare_Condition then
         Complicated_Expression
      else
         Complicated_Expression);

I might be able to quickly tell which complicated expression I need to
look at without having to study both. But with something like

X := (Rare_Condition then
         Complicated_Expression
      else
         Complicated_Expression);

Hera at a first glance it looks like the assignment to X is all about
Rare_Condition. Something like

X := (Complicated_Expression
      when
         Rare_Condition
      else
         Complicated_Expression);

Is even worse. Not only does it look like the assignment is about the
first complicated expression, I will probably end up studying that
expression before I even realize that is only rarely evaluated.

Of course it all comes down to what one is used to. Dmitry says the
leading 'if' makes things harder to read, but I find his examples much
more difficult.

Peter



  reply	other threads:[~2010-06-27 14:35 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       ` Gnat GPL 2010 available soon (conditional expressions) Georg Bauhaus
2010-06-27  8:37         ` 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 [this message]
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