Bijo
01-06-2007, 11:29 PM
System: WIN32 (XP)
Compiler: FreePascal
Libraries: -
I know I know: I should know the use of IF THEN ELSE, but you know what it is? I'm used to the IF ELSE and IF ELSE-IFs (etc.) of C++ and Perl and such. For example in C++ I sometimes did stuff like...
if (x <= y){
do_stuff();
}
else if (...){
do_otherstuff();
do_more();
}
else if (...){
do_this();
}
else{
do_that();
do_this();
}
It's so easy, 'cause whenever there's a keyword I just use { } and get it over with, even if there's one statement. I also just put a ; after every statement or expression or whatever, and I can easily use IF and ELSE-IFs (and an opional ELSE).
When I'd try something like that (the IF-ELSE and such) with Pascal, I'm just getting totally confused with something that should be so simple, and I try to keep things even simpler than I could have done, I almost even avoid the IF-THEN-ELSE with BEGIN-ENDs and just rely on many IFs alone sometimes.
Is that piece of code there above equivalent to....
if (x <= y) then begin
do_stuff; {or I could just remove BEGIN-END and ; here?}
end;
else begin
if (...) then begin
do_otherstuff;
do_more;
end;
if (...) then begin
do_this;
end;
else begin
do_that;
do_this;
end;
end;
Arrrgh! These kinds of things are the most annoying syntax critters I encounter(!), but for the rest I mostly love the language :) (though I wouldn't mind a # instead of <> )
(* Why not just make it easier and force a BEGIN-END and force the use of ; every every statement and after every END? *)
Compiler: FreePascal
Libraries: -
I know I know: I should know the use of IF THEN ELSE, but you know what it is? I'm used to the IF ELSE and IF ELSE-IFs (etc.) of C++ and Perl and such. For example in C++ I sometimes did stuff like...
if (x <= y){
do_stuff();
}
else if (...){
do_otherstuff();
do_more();
}
else if (...){
do_this();
}
else{
do_that();
do_this();
}
It's so easy, 'cause whenever there's a keyword I just use { } and get it over with, even if there's one statement. I also just put a ; after every statement or expression or whatever, and I can easily use IF and ELSE-IFs (and an opional ELSE).
When I'd try something like that (the IF-ELSE and such) with Pascal, I'm just getting totally confused with something that should be so simple, and I try to keep things even simpler than I could have done, I almost even avoid the IF-THEN-ELSE with BEGIN-ENDs and just rely on many IFs alone sometimes.
Is that piece of code there above equivalent to....
if (x <= y) then begin
do_stuff; {or I could just remove BEGIN-END and ; here?}
end;
else begin
if (...) then begin
do_otherstuff;
do_more;
end;
if (...) then begin
do_this;
end;
else begin
do_that;
do_this;
end;
end;
Arrrgh! These kinds of things are the most annoying syntax critters I encounter(!), but for the rest I mostly love the language :) (though I wouldn't mind a # instead of <> )
(* Why not just make it easier and force a BEGIN-END and force the use of ; every every statement and after every END? *)