lua-users home
lua-l archive

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

On Mon, Aug 12, 2002 at 10:45:48AM -0500, wrote:


> Not to mention the dangling else semi-ambiguity, which is my personal
> dislike
> for the C syntax. I have always found it disconcerting that you have to put
> a ;
> in:
>    if (a > 0) y = a;
>    else y = 1 - a;
> To me, the Pascal-like Lua syntax is clearer -- but it's just
> a personal prejudice, to be sure.

I personally dislike both C's and Lua's ways :)  The BASIC programmer
inside me likes to end structures with a specific ending, like ENDIF or
NEXT rather than the more generic "end" - In my experience it means it's
easier to detect certian types of error.  Where most BASIC's have the
parameters to NEXT optional, if you do supply it, the interpreter will
make sure you're not overlapping your loops etc.  I tend, when writing
quite complex code in Lua, to put a comment after the end to specify
exactly what it's ending, a for loop, and if etc.  Of course, the
compiler doesn't pay attention to these.

> On a semi-related topic, how do you all indent Lua "if" statements?
> Do you put the "then" on the same line as the "if" or on a line by itself?

if (foo == bar) then

or, sometimes if (foo == bar) then wibble; end;

I seem to be mildly unusual in my use of ; at the end of statements from
what I've seen, too.  Don't know why, just seems to make it easier to

Rob Kendrick -
Water, taken in moderation cannot hurt anybody.
		-- Mark Twain