[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: From: Norman Ramsey Re: Switch/Case statements revisited
- From: "XenoLiz" <xenoliz@...>
- Date: Sat, 10 Nov 2007 09:52:49 +0600
|> Date: Thu, 08 Nov 2007 20:21:50 -0500
|> From: Norman Ramsey <nr@eecs.harvard.edu>
|> Subject: Re: Switch/Case statements revisited
|> To: Lua list <lua@bazar2.conectiva.com.br>
|> Message-ID: <20071109012150.4749D1EB38E@labrador.eecs.harvard.edu>
|>
|> A few comments:
|>
|> * While I love Haskell/OCaml matching with pattern guards, I don't
|> see that as a good model for Lua, because Lua has no notion of
|> constant or constructor
It`s no true. `Nil`, `false` , `true`, 0.0, 1.0 ... {}, functions is a
constant.
On meta-lua `Let{..}, 'And{..} is may be matched
On LOOP Object-meta-table may be too, if you can release this.
|> * Of existing languages with case statements, the model I know of
|> that most closely fits Lua is the Icon programming language.
|> There as in Lua there are no special constants and the case
|> expression is simply another way of writing nested if's.
Icon:
case s of { "begin" : depth := depth + 1 "end" : depth :=
depth - 1 }
case i of { j + 1 : write("high") j - 1 : write("low") j
: write("equal") default : write("out of range") }
Is it simple? I was not understanding, it`s terrible, not contexted syntax.