[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: metatables for strings?
- From: Nagaev Boris <bnagaev@...>
- Date: Sun, 3 May 2015 16:33:37 +0000
On Sun, May 3, 2015 at 4:14 PM, Sam Putman <firstname.lastname@example.org> wrote:
> On Sun, May 3, 2015 at 8:32 AM, Nagaev Boris <email@example.com> wrote:
>> On Sun, May 3, 2015 at 3:27 PM, Dirk Laurie <firstname.lastname@example.org> wrote:
>> > I can't guess what you want.
>> I guess Sam wants strings to be like tables: each instance has
>> individual metatable.
> Precisely, but not if we have to pay for it.
> The string pointer has a metatable, so we can ("foo"):sub(1,1) and the like.
> It would be nice to be able to add to the metatable chain, so that values
> point to strings can have arbitrary methods, not only one set of privileged
> string functions.
If string instances had individual metatables, then they would be
individual types. I like the fact that all strings in Lua are of one
type. Can we write reliable code working with strings, if strings are
PS. I still like syntax "hello":sub(1, 4)
PS 2. Why no individual metatables for light userdata?