On 2/24/06, Pavol Severa <pavol.severa@gmail.com> wrote:
I imagine there are some formal problems:
1. a function call is a valid statement - still it would be nice if
its results were printed (except when it's nil)
Try putting a '=' before the expression or function call.
--
-alex
The '=' addition is really useful, if you look in lua.c
to see how it's done, the top of the stack is modified
just before it gets handed into lua:
> =math.sqrt(2) <--> return math.sqrt(2)
You can add whatever you want to the language this way,
without messing with the actual lua parser. Here's a few
of my "improvements", mostly to save key strokes.
> iter 27 <--> for i=1,27 do
> loop <--> end
This is copying syntax from a now-forgotten language, magicL.
In that language you could also define "commands", i.e.
functions without parentheses. So I implemented
> command print
After saying that,
> print x '=' 5 <--> print(x,'=',5)
now you can say
> iter 10
>> print i*i
>> loop
and get the expected result. Adding sh is another:
> sh date <--> os.execute('date')
Now,
> sh vi lua.c
> sh make
> sh lua
and edit yourself, and run a new copy of yourself, within yourself!
This language is a lot of fun.
rob