Language mavens: Is there a programming with "if then else ENDIF" syntax?
Adrian Cherry
acherry at btinternet.com
Mon Nov 16 12:16:46 EST 2009
Steve Ferg <steve.ferg.bitbucket at gmail.com> wrote in
news:ff92db5b-9cb0-4a72-b339-2c5ac02fbad0 at p36g2000vbn.googlegro
ups.com:
> This is a question for the language mavens that I know hang
> out here. It is not Python related, except that recent
> comparisons of Python to Google's new Go language brought it
> to mind.
>
> NOTE that this is *not* a suggestion to change Python. I
> like Python just the way it is. I'm just curious about
> language design.
>
> For a long time I've wondered why languages still use blocks
> (delimited by do/end, begin/end, { } , etc.) in ifThenElse
> statements.
>
> I've often thought that a language with this kind of
> block-free syntax would be nice and intuitive:
>
> if <condition> then
> do stuff
> elif <condition> then
> do stuff
> else
> do stuff
> endif
>
> Note that you do not need block delimiters.
>
> Obviously, you could make a more Pythonesque syntax by using
> a colon rather then "then" for the condition terminator.
> You could make it more PL/I-like by using "do", etc.
>
> You can write shell scripts using if ... fi, but other than
> that I don't recall a language with this kind of syntax.
>
> Does anybody know a language with this kind of syntax for
> ifThenElseEndif?
>
> Is there any particular reason why this might be a *bad*
> language- design idea?
I believe MATLAB has similar if syntax - please correct me if I'm
wrong.
From
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/if.html
"The if function can be used alone or with the else and elseif
functions. When using elseif and/or else within an if statement,
the general form of the statement is"
if expression1
statements1
elseif expression2
statements2
else
statements3
end
Adrian
More information about the Python-list
mailing list