[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (beta-rc1) now available
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 15 Jun 2011 10:32:17 -0300
> > The metatable of `string` is itself. It has a method __index.
> > So it seems to be a feature, not a bug. :-)
>
> Yes. But I cannot see what can be that feature.
> >From the sources, the __index field inside `string` is a function
> whose only purpose is to throw an error.
> Why is that function needed?? In all other module tables (like table,
> os, io, ...) indexing the table with an non-existent field simply
> returns nil.
It is used to detect errors like this:
print(s:fomat("%.4d"))
You should use 'rawget' in your tests for an __index field. (That is
how Lua accesses those fields, after all.)
-- Roberto
- References:
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, steve donovan
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, David Given
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, steve donovan
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Tomas Guisasola Gorham
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Mike Pall
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Patrick Rapin
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Dirk Laurie
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Patrick Rapin