lua-users home
lua-l archive

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


Matias Guijarro wrote:

Hello,

I find your approach interesting ; where may I find
the patch/source code for your new "command"
statement ?

I would like to give it a try...

Thanks in advance,
M.



Sorry to be slow in responding, our servers were being swapped,
and I lost a bunch of email.  I'm happy to share my code via email, though
it's not elegant, it's just for local use.  Also, even though I've been using
lua for less than a month, my code is already "old", a new version
of lua.c has been released.  The new version is even shorter than
the previous, and approaches the level of "art code", it will almost be
a shame to hack it, but that's what it's there for.

The idea of functions without parentheses, or "commands", has been
discussed in other threads, I think it's a good idea.  Being able to skip
the parentheses is a convenience for commands one types dozens
of times a day.  Further, they are a feature of competing languages.
We implement them line-by-line in the interpreter, the internal parser
is unaffected.  Only the most common ten or twenty functions we use
get turned into commands, for example, "print".  After

> command print

> print  aa   'howdy   '   137.5   <-->   print(aa,'howdy   ',137.5)

The basic idea is to replace spaces by commas, except in strings.
 You do have to remember to say 2*x and not 2  *  x, but even I can
remember that.  Also

> print(x) print(y)   <-->   print(x) print(y)

because we don't change anything when we see an open paren after
a command word.  This mod doesn't rise to the level of a language
change, but for us it's at least as useful as

> =2+2   <-->  return 2+2

I don't see the = mod in the "The Complete Syntax of Lua" either!

rob