[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: assignments in expressions?
- From: Will Leshner <will@...>
- Date: Thu, 11 Jan 2001 10:10:55 -0800
I agree. I think all statements should return values. That is a very powerful feature I'd like to see in Lua. Scheme, for example, has such a concept.
On Thursday, January 11, 2001, at 12:41 PM, Lenny Palozzi wrote:
> In the code below I would like to assign 'c' the return value of function
> 'f', and have c(or the return value of function 'f') compared to the
> right-hand side. From the looks of the Lua syntax, you can't do this in Lua.
>
> I get:
>
> error: `)' expected;
> last token read: `=' at line 6 in file `t2.lua'
>
> Can Lua be easily changed to handle this? Just curious, as I sometimes write
> similar code in C.
>
> function f()
> return 1
> end
>
> c=0
> while (c=f()) == 1 do
> print(c)
> end
>
> Thanks,
> -Lenny
>
>