Is it possible to override some methods of standard string class so they can be invoked with the dot operator? For example:
s = "hello world"
print(s.len())
For types which are not tables or full userdata, each type has a metatable. That is, rather than each individual string having its own metatable, all strings share the same metatable.
The Lua standard string library, by default, assigns this metatable to the string table. So if you want, you can add entries to string.
Granted, len makes no sense, as we have # to compute that. And you would need to use : calling syntax if you want to pass the string as the first parameter.
callmetatable, but you would have to store the string in some containing object. But not with the string itself, if I am right. using#is probably easier.s:len()) - unless you want to writes.len(s). Have you read Programming in Lua: OOP?