lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


steve donovan wrote:
[...]
The variable match syntax is nice and very general. My only concern is
that the pipe character tends to have other associations. Is it
Lua-ish?

It looks stolen from functional languages, IIRC --- most languages of the Haskell or ML stable support this kind of pattern matching. It is, indeed, great.

(Although the use of special characters doesn't really fit the Lua style, which normally goes for keywords. Perhaps:

match k
  with 10, 11 then return 1 end
  with 12 then return 2 end
  with i if 13<=i and i<=16 then return 4 end
end

(That also ends up having a nice simple grammar, too.)

--
David Given
dg@cowlark.com