As discussed elsewhere, Nexxi is a block-oriented language. By this I mean that the language defines it’s structure in terms of blocks that are passed to controller “functions” (we’ll call them block headers from now on) that then call the block appropriately. In standard Java/C++/C syntax, a block is enclosed in curly braces:
{
doSomethingInABlock();
doSomethingElseInABlock();
}
C-derived languages also allow most control structures to accept a single statement in place of a block, as follows:
if( x == y )
doStuff();
This latter syntax has always seemed wrong to me, not to mention a bit dangerous when it comes to debugging. The reason is that most programmers are used to indentation marking structure, and in fact skim code on the indentation, not the actual syntactic markers. For instance, it is really easy to read the following code as one if statement with a block:
if( x == y )
doStuff();
doOtherStuff();
What I’m thinking is that Nexxi will also offer two block styles, but that the second one will be an indentation-sensitive style similar to that in Python. For instance:
if( x == y ):
blockStep1();
blockStep2();
else:
doSomethingCompletelyDifferent();
In this example, the colon (:) marks the beginning of a whitespace sensitive block. If the line ends without further tokens, the block is all following statements that are indented under the block header.
if( x == y ): doStuff();
In this example, the colon is followed by more tokens before the end of the line, and so the block runs until the end of the line.
Of course, this may not be a brilliant plan. On the plus side, it does provide a syntax that always means what it looks like it means, a syntax that contains very little visual noise. And it is a syntax that will feel comfortable to those JPython programmers who might want to switch to Nexxi. On the minus side, it does mean that the language will accomodate two very distinct coding styles, styles that may or may not work very nicely together. It also complicates the parser, to some extent, and eliminates a piece of Java some programmers may really miss.
In any event, this one is still up in the air. However, as a means of demonstrating and playing around with the syntax, I will alternate between the two for examples from here on in.
| in Design: | |
| on site: |
Markdown: The kinds of formatting markup you'd use in an email will probably work here. For more details on what you can do, check out the Markdown docs.