[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: bitwise ops and opcodes
- From: Gavin Wraith <gavin@...>
- Date: Fri, 10 Feb 2006 16:42:52 GMT
<062debf64d.wra1th@wra1th.plus.com>
<d46ca6c20602100747o27c75203lcd8359eb742bd6fa@mail.gmail.com>
In-Reply-To:
<d46ca6c20602100747o27c75203lcd8359eb742bd6fa@mail.gmail.com>
X-Organization: Home
User-Agent: Messenger-Pro/1.00c (MsgServe/1.00a) (RISC-OS/5.10) POPstar/2.05
Reply-To: lua@bazar2.conectiva.com.br
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
In message
<d46ca6c20602100747o27c75203lcd8359eb742bd6fa@mail.gmail.com> you wrote:
> > One more snippet about syntax: RiscLua uses "\" as an
> > abbreviation for "function" and "=>" as an abbreviation
> > for "return". This gives the potential for a snappier
> > Haskell-like syntax, e.g.
> >
> > curry = \(f)=>\(x)=>\(y)=>f(x,y) end end end
> >
> > Yes, I know it is out of the Pascal-style tradition of
> > using words, but I find it very readable. It is an extremely
> > simple patch to llex.c.
>
> I've been craving for that for years and I didn't know it.
> Can you post the patch to llex.c to the list?
---- diff for llex.c,v 2.19 2006/02/06 18:28:16 roberto
in static int llex (LexState *ls, SemInfo *seminfo) { ...
Replace, at line 368
-- case '=': {
-- next(ls);
-- if (ls->current != '=') return '=';
-- else { next(ls); return TK_EQ; }
-- }
with
++ case '=': {
++ next(ls);
++ switch(ls->current) {
++ case '=': next(ls); return TK_EQ; break;
++ case '>': next(ls); return TK_RETURN; break;
++ default: return '='; }
++ }
++ case '\\': {
++ next(ls);
++ return TK_FUNCTION;
++ }
--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/