[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: At sign ``@'' in key
- From: Rena <hyperhacker@...>
- Date: Sat, 22 Dec 2012 13:59:41 -0500
On Sat, Dec 22, 2012 at 1:40 PM, Grizzly Bear <6grizzlybear@gmail.com> wrote:
> Thank you both! Problem solved.
>
> tab.var@addr = 1
>
> is terser than
>
> tab["var@addr"] = 1
>
> saving 3 chars and I'm a miser. That's why I liked to be able to do it.
>
> Wei
>
> On Wed, Dec 19, 2012 at 6:26 PM, Luiz Henrique de Figueiredo
> <lhf@tecgraf.puc-rio.br> wrote:
>>
>> > But I haven't been able to do
>> > tab.var@addr = 1.
>> >
>> > I'm using Lua 5.1.5. Any suggestions?
>>
>> Not for 5.1, but in 5.2 you can tell the lexer that @ is a letter by
>> editing lctype.c and rebuilding. Not that I recommend you to...
>>
>
I had pondered before the idea of allowing '@' and '$' in names, at
least at the beginning. That then led to the idea of functions named
only @() and $(), which function like prefixes in that they don't need
parentheses for a single argument, e.g.:
$ = tostring
x = {}
print($x) --> prints "table: 0x......"
The idea being mainly to avoid having to wrap things in tostring() and
tonumber() everywhere, which gets ugly fast.
--
Sent from my Game Boy.