Sujet : Re: Command Languages Versus Programming Languages
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.unix.shell comp.unix.programmer comp.lang.miscDate : 05. Apr 2024, 17:30:12
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uup8ul$1fr2t$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 05.04.2024 01:29, Lawrence D'Oliveiro wrote:
On 4 Apr 2024 11:20:48 GMT, Stefan Ram wrote:
And let me tell you, when you start getting into that kind of nested
stuff with not parentheses in view, even the "?:" notation can start
looking pretty darn mysterious to some folks.
This is where indentation helps. E.g.
a =
b ?
c ? d : e
: f ?
g ? h : i
: j;
Indentation generally helps. In above code (in my book) it's not
that clear [from the indentation], e.g. where the last ':' 'else'
belongs to. So I'd have lined the colons up with the respective
'?'. (YMMV.)
Not all languages differentiate (per syntax) a conditional command
from a conditional expression. Here are the two forms supported by
Algol for both, statements and expressions (here the examples are
both depicted for expressions only)
a :=
( b | ( c | d | e )
| ( f | ( g | h | i )
| j ) );
The parenthesis are not used for grouping, but are the alternative
form for IF/THEN/ELSE/FI
a := IF b
THEN
IF c THEN d ELSE e FI
ELSE
IF f THEN
IF g THEN h ELSE i FI
ELSE j FI
FI
Pick your choice depending on the case (or taste).
Janis