[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: block return semantic
- From: David Jeske <jeske@...>
- Date: Tue, 26 Jun 2001 09:52:46 -0700
I'd like to formally request something that I suggested as an
offhanded comment a short while ago. Lua should allow the last element
in a block to be an expression, and if so, implicitly return it as the
return value of the block. If this is done, Lua will be much more
useful as an interactive shell.
Here is an example of attempting to use Lua interatively:
mozart:~/Project/Lua/lua31/bin> lua
Lua 3.1 (alpha) Copyright (C) 1994-1998 TeCGraf
> 1 + 1;
lua: parse error;
last token read: "1" at line 1 in file (dostring) >> 1 + 1;
> sin(45);
> a = { 1 , 2};
> a[1];
lua: parse error;
last token read: ";" at line 1 in file (dostring) >> a[1];
Here is an example of the kind of thing which is useful in Python and
should happen in Lua:
mozart:~/Project/Lua/lua31/bin> python
Python 1.5.2 (#1, Sep 17 1999, 20:15:36)
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 1 + 1
2
>>> import math
>>> math.sin(45)
0.850903524534
>>> a = [ 1 , 2 ]
>>> a[0]
1
--
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net