lua-users home
lua-l archive

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


Why the need to do that?  That leads to hard-to-read code that is no more
efficient than a easier to understand layout.  Are we going to have an
Obfuscated Lua Code Contest?

What is wrong with this way?  It is no different in functionality and easier
to understand.

c = f()
while c == 1 do
  print(c)
  c = f()
end

Steve 'Sly' Williams - Code Monkey - http://www.kromestudios.com

> 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