lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 8/30/05, David Given <> wrote:
> ...Lua and Pascal believe that the syntax to do this belongs in
> the thing that is performing the action --- if...then...else...endif.
> C and Javascript believe that it's better to have seperate syntax
> for doing this; the thing that performs the action operates on a
> *single* statement --- but you can wrap up a statement list into
> a single statement.

Actually, in this respect Pascal is no different from C, except
for using `begin' and `end' instead of { and }.  I pointed out this
in a previous posting in the thread.

One can observe that there are several possibilities here.
-- Explicit, keyword-delimited start, end, and inner parts of
   control statements (Lua, Ada, Clu, Modula, Dylan, etc).
   The are variants of this, but in any case the keywords
   in use are specific to the corresponding control statements.
-- As above, but with dedicated characters or combinations
   instead of keywords.
-- Each part of a control statement is a statement, including a
   compound statement (a block).  So there has to be a universal
   construct for building a block, such as do--end, begin--end,
   {--}, [--] etc, to be used wherever the body (or part) of a control
   statement must be compound (Pascal, C and descendants).
-- There is only one, universally applied kind of a block
   statement (as above), but it is mandatory to use it wherever
   a statement is nested within a control statement -- no simple
   statements allowed as parts (bodies) of control statements
   (Perl, Rebol).
-- Using offset to indicate nesting (occam, Miranda, Haskell,
   Python).  In Haskell, one has the choice between using
   offsets and delimiting with braces: { and }.

> Ultimately, this is purely a matter of personal preference

Well, not only.  The languages of the third group mentioned
are notorious for having to disambiguate where an `else' belongs
when `if's are nested.  That problem, btw, would have been
avoided, had the language designers introduced something else
(say, `when') for one-branched `if's, and left the `if' for two-branch
use only.

> ... the only opinion that matters is that of the Lua devs

Of course.  We are only talking. :)