Re: [PHP-LANG] Approaching the First Draft [of a language spec]

[email protected] (Rasmus Lerdorf)
Newsgroups php.dev,php.lang
Message-ID <[email protected]>
The way I see this actually working is that someone sits down and writes a
first draft of this thing.  Probably quite incomplete, but at least it
will lay out the framework.  From there we complete it as a group.

Historically not too many things have been accomplished through concensus
and voting and whatever other structure you might put in place.  You need
to start with some sort of base usually hammered out by either a single
person or a very small group.

At this point I would prefer to see someone like Sascha just sit down and
write this base document.  It should be a complete and unambiguous
language spec using some sort of established language description syntax.
However, it should also include mere-mortal interpretation hints.
Something like the following.  I am using BNF since that is what I am
familiar with, but there might be some better alternatives.  I think the
important part is to have the combination of the rigid definition of
something like BNF combined with the user-friendly explanation and example
text:

  <while-statement> ::= while ( boolean_expr ) [ statement_sequence ] |
                                               [ : statement_sequence endwhile ]

  The while statement has two syntactical variations.  The first and most
  traditional is a simple statement sequence:

     while( $a > 1 ) $a = 0;

  Remember that statement sequences can contain multiple statements inside
  braces, so the following is also a valid syntax for the while statement:

     while( $a > 1 ) { $a = 0; $b = 0 }

  The second variation is a carryover from the early days of PHP and it is
  still used today as it makes reading code containing large blocks of raw
  HTML easier on the eyes:

     while( $a > 1 ): $a = 0; endwhile;

  Again, multiple statements are valid:

     while( $a > 1): { $a = 0; $b = 0; } endwhile;

  This syntax has implied statement grouping which means it is valid to
  drop the braces around the statement sequence:

     while( $a > 1): $a = 0; $b = 0; endwhile;

  And finally, what this syntax was intended for:

     <?php while( $a > 1): ?>
     <B>Block of raw HTML</B>
     <?php endwhile ?>


-Rasmus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.