General Category > General Discussion

Overview of syntax

(1/2) > >>

lerno:
I recommend the following two sites for overview of different types of syntax:

https://rosettacode.org
http://rigaux.org/language-study/syntax-across-languages.html

bas:
Having keywords written out (like begin or end) always reminds me of my very early Basic days.
Especially fully capitalized versions (BEGIN .. END) really scream 1980's.

lerno:
For me, begin / end is very much Pascal.

However, there is something to be said for "some start"-end.

Consider this:

K&R

--- Code: ---func int test() {
   if (foo == 45) {
      do_a();
   } else {
      do_b();
   }
}

--- End code ---


Allman

--- Code: ---func int test()
{
   if (foo == 45)
   {
      do_a();
   }
   else
   {
      do_b();
   }
}

--- End code ---

Ruby-like

--- Code: ---func int test()
   if (foo == 45) do
      do_a();
   else
      do_b();
   end
end

--- End code ---

Here I'd actually say that the Ruby-like syntax retains the positive terseness of K&R (no special lines just for the start of a block), with the readability of Allman (blocks are visually extremely easy to make out). The only thing I don't like about this style is that "end" seems such a long keyword.

bas:
I must say that I do find the Ruby version quite readable. This surprised me. Maybe the end keyword is easier on the eyes then the }.
If never like the Allman style where half your screen seems filled with lines only containing a single character ({ }).

Changing the curly brackets to begin/end keywords, does change the language a lot at the surface (what people view first)...

lerno:
Definitely, I'm not suggesting anything other than { } for C2. (Unless we find some reason that changing { } would make things much much more readable.

Navigation

[0] Message Index

[#] Next page

Go to full version