[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Syntax request (coming to terms with false)
- From: Tom Wrensch <twrensch@...>
- Date: Fri, 18 Jan 2002 15:17:56 -0800 (PST)
On Fri, 18 Jan 2002, Tom Wrensch wrote:
> Okay, I see your point. I've always thought that allowing both assignment
> and IF-THEN-ELSE statements as expressions was a good thing.
Sorry, I just realized this statement might need some explaination. What I
mean is that one could do this:
local x,y
x = (y = 1) + 1
print(x,y)
And would get:
2 1
Or this:
x = if x > MaxValue then x else x + 1 end
And have x incremented if it is less than MaxValue.
This last point would be handy when using an if to decide which return
value to use. For example:
define factorial(n)
return (if n==1 then 1 else n*factorial(n-1) end)
end
Rather than: (put all on one line for better comparison to above)
define factorial(n)
if n==1 then return 1 else return n*factorial(n-1) end
end
This is *not* a proposal. While I would like Lua to evolve this way, I
think the language is doing just fine without me meddling. Be sure that
I'll yell if I think otherwise!
- Tom Wrensch