lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sun, May 3, 2015 at 4:14 PM, Sam Putman <atmanistan@gmail.com> wrote:
>
>
> On Sun, May 3, 2015 at 8:32 AM, Nagaev Boris <bnagaev@gmail.com> wrote:
>>
>> On Sun, May 3, 2015 at 3:27 PM, Dirk Laurie <dirk.laurie@gmail.com> 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
> which
> 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
non standard?

PS. I still like syntax "hello":sub(1, 4)

PS 2. Why no individual metatables for light userdata?

-- 


Best regards,
Boris Nagaev