[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: Wed, 20 Sep 2006 11:15:41 +0200
Well a problem is that otherwise should be mandatory or we shouldn't put comma after when conditions because this can be a trouble for the grammar rule reduction.
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Philippe Lhoste
Sent: Wednesday, September 20, 2006 10:55 AM
To: lua@bazar2.conectiva.com.br
Subject: Re: Default value in function parameters?
Rici Lake a écrit :
> On 19-Sep-06, at 11:45 AM, Grellier, Thierry wrote:
>> 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
>> }
>> }
>
> I actually like "when" (although i use it with "otherwise" because
> "else" is already in use).
And I find it clearer, I searched something after the else... Sounds
corny. Of course, that's more keywords...
> But more Lua like would be:
>
> a = { a = 1,
> b = { b = 2,
> c = {native = 1, rock = 2}[style] or 0
> }
> }
Argh! WOULD BE! I tried it, and wondered by I had syntax errors...
Indeed, it seems a bit strange at first, but it is quite elegant in its
simplicity (and no new keyword...).
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --