[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: case statement for Lua
- From: Bret Mogilefsky <mogul@...>
- Date: Sun, 13 Apr 1997 17:14:55 -0700
Maybe it's just me, but does anyone else find this syntax, well,
gruesome? Sorry, Norman, don't mean to offend, just expressing an
"Why, that's the second biggest monkey head I've ever seen!" --Guybrush
"LeChuck's dead. I blew him into a million gooey pieces." --Guybrush
Bret Mogilefsky ** email@example.com ** Programmer, LucasArts
>From: Norman Ramsey[SMTP:firstname.lastname@example.org]
>Sent: Sunday, April 13, 1997 10:45 AM
>To: Bret Mogilefsky
>Subject: case statement for Lua
>I felt the need for a case statement in Lua, so I added one.
>Unfortunately I had to change the virtual machine as well as the
>compiler, because I couldn't figure out how to duplicate the element
>on top of the stack using only the existing operators.
>Still, Lua is so clean that I added or changed no more than 30 lines
>I borrowed syntax from Modula-3 for the case statement (with one
>slight change); here's an example:
> x = "bar"
> case x of
> | "foo" => y = 1
> | "bar" => y = 2
> else => y = 99
> print(x, y)
>Some day when I have another hack attack, I'll improve the patch so
>you can write multiple expressions to the left of the arrow.
>This is a patch file for lua-2.5. To build it, unpack the lua-2.5
>distribution, change to the toplevel directory (called 'lua' in the
>distribution), and run
> patch < this_patch_file
> (cd src; make parser)