Yeah, it's always fantastic when a forgotten brace induces a non-sensical error 3/4 of the program down. Of course Spin just goes on it's merry way and does nothing close to what you thought you asked it too. Pick your poison.
Most editors today will already be showing you that you have mismatched braces before you even hit the compile button. Not so if you have misplaced a whitespace indent. Then you are blissfully happy until you run the code, it misbehaves and you have to fish around for ages just to find a missing/extra tab. Blech.
Even with explicit delimiters, good programmers use indentation to indicate nesting and scope. To me, braces are nothing more than vertical space-gobbling gingerbread that clutter, rather than illuminate, a program. Now, if you wanted to write your entire program on a single line, obfuscated-Perl-style, that's another matter entirely.
Most editors today will already be showing you that you have mismatched braces before you even hit the compile button. Not so if you have misplaced a whitespace indent. Then you are blissfully happy until you run the code, it misbehaves and you have to fish around for ages just to find a missing/extra tab. Blech.
True but you could argue that using indenting for block structure makes it easier to verify correct block structure visually just by looking over the code. There is no case like this in C where the code *looks* right but is in fact wrong.
if (this == that)
printf("first this\n");
printf("then that\n");
The only structure I've noticed is that unlike C all blocks require braces. The single line "block" with no braces caused me so many problems that I imposed the rule about all blocks require braces on myself years before learning perl!
True but you could argue that using indenting for block structure makes it easier to verify correct block structure visually just by looking over the code. There is no case like this in C where the code *looks* right but is in fact wrong.
if (this == that)
printf("first this\n");
printf("then that\n");
This is why I like the Perl way of blocking. ALL blocks require braces around them. Even single line ones!
You have to realize that Perl is not so much the product of "intelligent design" but "guided evolution." As such, it has many similarities to natural language. (Larry Wall is a linguist, after all.) I rather like constructs this one:
$text .= next($file) unless eof($file);
Perl's "lazy Booleans" are another nice feature (that Spin would benefit from):
open DAT, "<$filename" or die "$filename cannot be opened."
It's so much more succinct and natural than the braced alternative.
Even with explicit delimiters, good programmers use indentation to indicate nesting and scope. To me, braces are nothing more than vertical space-gobbling gingerbread that clutter, rather than illuminate, a program.
Phil, maybe you didn't know this about C, but you can put the braces on the same line as a statement. It's possible to write the same function in C with the same number of lines and indentation that are used in Spin. I don't understand why you think C takes up more vertical space.
Except putting the braces on the same lines as statements starts to make the code look like a cluttered mess. I will always put my braces on their own line where they not easily missed and don't clutter the statements. They are not wasting space they are boldly telling you the structure of your code. Like paragraph breaks in written English.
Comments
-Phil
The only structure I've noticed is that unlike C all blocks require braces. The single line "block" with no braces caused me so many problems that I imposed the rule about all blocks require braces on myself years before learning perl!
This is why I like the Perl way of blocking. ALL blocks require braces around them. Even single line ones!
Perl's "lazy Booleans" are another nice feature (that Spin would benefit from):
It's so much more succinct and natural than the braced alternative.
-Phil
It's probably due to the programming style I use for Perl:
-Phil
Therefore I use PropBasic & PASM.
Cheers, Friedrich