lua-users home
lua-l archive

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


alex.mania@iinet.net.au 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
string:

$ lua
Lua 5.1.2  Copyright (C) 1994-2007 Lua.org, PUC-Rio
> f = function(s) return s .. '*' end
> print(f "a" .. "b")
a*b
> g = function(s) return 4 end
> print(g "a" .. "b")
4b
> 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.

Doug

-- 
Innovative Concepts, Inc. www.innocon.com 703-893-2007 x220