lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index] wrote:

> Not quite.
>    f "A" .. "B"
> will raise a syntax error, presumably to reduce confusion.

As was pointed out in another thread, this does not produce a syntax
error but rather a run-time error. And only if 'f "A"' does not return a

$ lua
Lua 5.1.2  Copyright (C) 1994-2007, PUC-Rio
> f = function(s) return s .. '*' end
> print(f "a" .. "b")
> g = function(s) return 4 end
> print(g "a" .. "b")
> h = function(s) return end
> print(h "a" .. "b")
stdin:1: attempt to concatenate a nil value
stack traceback:
        stdin:1: in main chunk
        [C]: ?

Note that the second one (g) succeeds only because Lua runs tostring()
on the number returned by g(); that's another debate for another day.


Innovative Concepts, Inc. 703-893-2007 x220