lua-users home
lua-l archive

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

I think this proposition is interesting, but a bit half-hearted.

As someone stated, the C language is one of the oldest and most widely used
language, as its syntax was 
a source of inspiration for many other languages (C++, Java, C-shell, to
name but a few).

So instead of "or", "and" and "not", we should use the familiar "||", "&&"
and "!".

And drop these silly and long-to-type "do", "then", "end" and switch to the
widely used "{" and "}".

Of course, this will change the syntax of tables, we should use eg. <"a", 1,
x="k">, with some ambiguity 
to lift with operators, I leave that as exercise.

Forget this [[literal string]] syntax, and --[[multiline comment]] one, this
can be trouble when writing eg. 
t1[t2[n]] inside. Let's use ""literal string"" and  /*multiline comment*/,
that's much better!

And why this ".." concatenation? Let's use "&", shorter and clearer!

OK, I won't continue any longer.

If someone want some alternate syntax, he is free to implement it, since he
has the source. Don't forget 
to rename the new language with another name...
Or perhaps a simplier way would be to pick a C-like language, but it may be
less powerful and flexible 
than Lua...

I agree that ~ being a dead key (on French keyboard too), it is a bit
annoying, but really a minor 
annoyance. By the way, when I type ~ followed immediately by =, on my French
system, I get ~= 
because the system sees that the combination doesn't do a valid character in
the current character set. 
And don't forget you have to use the ~ character in C too, although probably
less frequently.

The "use # as comment instead of --" leaves me even more puzzled... Hitting
two keys instead of one isn't 
time consuming (you don't even have to search for the other key) and on my
French keyboard, it is even 
faster to type -- (direct access, on regular or numeric keyboard) than # (I
have to push down the AltGr 
key to have it, as for ~{[|\ and so on). BTW I saw that another language (I
forgot which one) uses this -- 
notation for comments.

Personnally, I like the little syntax peculiarities of Lua, they save us
from the bore of having all the 
languages alike...
As long as they are not too exotic! I wouldn't like a language using . for
affectation, % for equality or , for 
string delimiter...
And there are enough differences to remind us it is another language. If we
use very similar languages, it 
is harder to remember the differences.

Perhaps I have a special way of thinking (I doubt so), but when I start
programming in a language, I take 
the mindset of this language.
I know I have to use Len(s) in VB, strlen(s) in C and string.len(s) in Lua5.
I know that I have to write:

' In VisualBasic
For i = 1 To 10

	subItems(i) = "Item" & i

Next i

// In C++
for (int i = 0; i < 10; i++)
	sprintf(buf, "Item%d", i);
	subItems[i] = strdup(buf);  // Or use a string class...


-- In Lua
for i = 1, 10 do
	subItems[i] = "Item" .. i

Sometime, when go back to a language I didn't use for a long time, I can do
some mistakes (forgetting 
'do' or 'then'), but after a short while I get used to the syntax and go on.

It is not the first time people ask for syntax changes (~= being one of the
most disturbing...), and most of 
the time, the Lua authors wisely ignored these requests.
The current syntax works well, it is the style of Lua, and it shouldn't be
changed unless there is an 
excellent reason (more than "I am more used to this notation"...).


Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist

HoHoHo! Seid Ihr auch alle schön brav gewesen?

GMX Weihnachts-Special: Die 1. Adresse für Weihnachts-
männer und -frauen!

+++ GMX - die erste Adresse für Mail, Message, More! +++