[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: patch: C-style string lexing
- From: David Manura <dm.lua@...>
- Date: Thu, 31 Jan 2008 03:38:28 +0000 (UTC)
Eric Tetz writes:
> > On Jan 30, 2008 5:20 PM, Luiz Henrique de Figueiredo wrote:
> > > This will break expressions like f "A" "B", which is interpreted as
> > > f("A")("B").
> Well, scratch that idea then. :)
How about constant folding string concatenations? This would require only an
implementation change. It is currently done for other operators:
$ echo 'return 2+3' | ./luac -p -l -
main <stdin:0,0> (3 instructions, 12 bytes at 0x680e28)
0+ params, 2 slots, 0 upvalues, 0 locals, 1 constant, 0 functions
1 [1] LOADK 0 -1 ; 5
2 [1] RETURN 0 2
3 [1] RETURN 0 1
$ echo 'return "a".."b"' | ./luac -p -l -
main <stdin:0,0> (5 instructions, 20 bytes at 0x680e28)
0+ params, 2 slots, 0 upvalues, 0 locals, 2 constants, 0 functions
1 [1] LOADK 0 -1 ; "a"
2 [1] LOADK 1 -2 ; "b"
3 [1] CONCAT 0 0 1
4 [1] RETURN 0 2
5 [1] RETURN 0 1
I wonder whether the right-most associativity of concatenation would complicate
this though.