lua-users home
lua-l archive

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

On Wed, Nov 20, 2013 at 3:26 AM, Sir Pogsalot <> wrote:
> I think this sort of thing has an official name... in Ruby the last
> statement -- what it evaluates to -- gets returned if it isn't explicitly
> preceded with a 'return '.  In Lua you cannot have expressions in the middle
> of nowhere.  You can have s2 = a * b, but you can't have a * b.  It might
> look a tad confusing to have s2 = a * b and expect that value to be returned
> if you're reviewing the code...

Just for historical background: Pascal and BASIC use this behavior
exclusively. In these languages, the way that you return a value from
a function is to assign the value to the name of the function. There's
no "return" statement at all. (Modern BASIC exposes "Exit Function" as
a way to return from the function without running off the end of it,
but you still have to exclusively assign the return value before you
get that far. Pascal might offer a similar feature but I haven't used
it in 20 years.)

/s/ Adam