Re: help with lua style and syntax
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: help with lua style and syntax
- From: Joshua Phillips <jp.sittingduck@...>
- Date: 2012年10月18日 13:45:14 +0100
On Thu, Oct 18, 2012 at 01:18:00PM +0100, David Collier wrote:
> in C I can write:
>
> if ( passed = myFunction( x , y , &z ) )
> && ( passed = mySecondFunction( z, &q ) )
>
> which is preferable to
>
> passed = function(x, y, &z)
> if ( passed )
> {
> passed = mySecondFunction( z, &q ) )
No it isn't.
> Now Lua allows me to return more than one value, so I can write
>
> passed, z = myFunction(x, y)
>
> but is there any way in Lua I can write
>
> if passed, z = myFunction(x, y)
>
> and set both passed and z, but then test 'passed' ??
No, thankfully.
> It would allow me to do:
>
> if ( passed, z = myFunction(x, y) )
> and ( passed, q = mySecondFunction(z) )
> and ( passed, result = myThirdFunction(q) )
>
> which is a lot more comapct than what I'm writing at present.
Compact, maybe. It's much better to make software easy to read, and that
doesn't necessarily mean making it compact.
See also: Perl golf.