Nobody wrote:
On Mon, 16 Nov 2009 08:54:28 -0800, Steve Ferg wrote:
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.
Does anybody know a language with this kind of syntax for
ifThenElseEndif?
BBC BASIC V had if/then/else/endif (it didn't have elif).
I forgot about that one. :-(
I used to do this in order if I wanted to avoid a lot of indentation:
CASE TRUE OF
WHEN <condition>
do something
WHEN <condition>
do something
OTHERWISE
do something
ENDCASE
"make" has if/else/else/endif (it doesn't have a dedicated elif, but
"else if ..." behaves like elif rather than starting a nested "if").
Is there any particular reason why this might be a *bad* language-
design idea?
Blocks can be useful for other reasons (e.g. limiting variable scope), so
if you already have them, you don't need to provide dedicated blocks
for control constructs.
--
http://mail.python.org/mailman/listinfo/python-list