[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Default value in function parameters?
- From: "Grellier, Thierry" <t-grellier@...>
- Date: Tue, 19 Sep 2006 18:45:19 +0200
Just let me return you the question: why you would really not like
something like this to happen?
I think that conditional expressions are extremely useful when it deals
with configuration which is the initial aim of Lua after all. If
properly use it can make the code more readable, especially for non
programmers.
To my mind, a high level programming language's goal is to make thing as
close as possible to natural language.
So, I would prefer to be able to write something like (VHDL flavor, and
yet another even more disturbing keyword :-) knowing that if elseif...
could be reused)
style = "native"
a = { a = 1,
b = { b = 2,
c = 1 when style == "native",
2 when style == "rock",
0 else
}
}
rather than
style = "native"
a = { a = 1,
b = { b = 2,
}
}
if style == "native" then
a.b.c = 1
elseif style == "rock" then
a.b.c = 2
else
a.b.c = 0
end
or
style = "native"
a = { a = 1,
b = { b = 2, c = f(style)
}
}
function f(style)
...
end
which disseminates the code, and well looks like coding.
But this has probably a noticeable impact on grammar. But I wonder, how
many people with hard size constraints really embed lua compiler?
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Vyacheslav
Egorov
Sent: Tuesday, September 19, 2006 4:45 PM
To: Lua list
Subject: Re: Default value in function parameters?
Grellier, Thierry wrote:
> Maybe "else' is a better choice.
Take a look at this http://docs.python.org/dev/whatsnew/pep-308.html.
Do you really want something like that happen with Lua?
--
e.v.e