[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Syntax/implementation question
- From: Nagaev Boris <bnagaev@...>
- Date: Wed, 27 Jul 2016 20:16:22 +0300
On Wed, Jul 27, 2016 at 7:18 PM, Daurnimator <quae@daurnimator.com> wrote:
> On 27 July 2016 at 19:20, Martin <eden_martin_fuhrspam@gmx.de> wrote:
>> Hi all,
>>
>> I'm experimenting with lua syntax and cannot understand why in
>> interpreter I'm getting such output
>>
>> Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
>>> print(1), print(2), print(3)
>> 1
>> 2
>> 3
>> nil nil
>>
>> When running this code from standalone file output is
>>
>> $ lua test_something.lua
>> lua: test_something.lua:1: syntax error near ','
>>
>> which is what I awaiting.
>>
>> Any hints?
>>
>
> The 5.3 REPL attempts to prefix code with `return `
> i.e. you are running:
> `return print(1), print(2), print(3)`
> The argument evaluation order is undefined (so you're lucky you see
> 1,2,3 in order).
> The 'nil, nil' output is the return value of that expression: print
> doesn't return anything, but when you have a subsequent return value
> the 'nothing' is coerced to `nil`.
>
Why does it print "nil, nil" and not "nil, nil, nil"?
--
Best regards,
Boris Nagaev