lua-users home
lua-l archive

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


And to be clear, you'd also have to preface every user-entered command
with "return " before handing off to lua_dostring.

-----Original Message-----
From: Curt Carpenter [mailto:curtc@microsoft.com] 
Sent: Tuesday, June 26, 2001 10:13 AM
To: Multiple recipients of list
Subject: RE: block return semantic


Seems like you could easily modify the stand-alone interpreter to do
this by checking the return value and printing it if it's non-nil. Lua
is the language, not the stand-alone interpreter. 

-----Original Message-----
From: David Jeske [mailto:jeske@chat.net] 
Sent: Tuesday, June 26, 2001 9:53 AM
To: Multiple recipients of list
Subject: block return semantic


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