lua-users home
lua-l archive

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


> Joshua Jensen wrote:

> Still, being able to do something like:

> function Number.tostring(num)
>     return "Number: " .. num
> end

> num = 55
> print(num:tostring())

> is very, very cool.

I don't think so. I like the functional way I can program with Lua. That
is the main reason why I using Lua. If I would like very cool
oo-Programming then possible I would change to Ruby. But I dislike all
this automatic stuff. I prefer to write long meaningfull variable names,
I prefer to write math.sin() instead of sin() and so on.

> For Sol, those metatables exist as regular tables called Number,
> String, etc.  This is an extension of the Lua 4.1 work4 mechanism

> (which I hope the Lua team will adopt)

I hope they will not going in this direction. Instead they should
concentrate on a extreme stable, free of bugs, well defined base, good
documentation, ...

Instead of such specials: why gsub() doesn't support the plain flag like
strfind()...

> > I wrote:

> > Please let me know why gsub() doesn't accept a plain option?

> Roberto wrote:

> I guess the main reason was that it is not very common the use of gsub
> over a fixed string. Anyway, there is an easy way to protect a
> pattern:

>  function plaingsub (s, p, r)
>    p = gsub(p, '(%W)', '%%%1')
>    return gsub(s, p, r)
>  end

I feel very bad to use on the one side:

strfind(...)       -- without a flag
strfind(...,true)  -- true ist the plain flag

and on the other side

gsub(...)          -- without a flag but
plaingsub(...)     -- to protect a pattern

Its not clean, its not easy, its a hack, its not a well designed base. I
don't accept the answer from Roberto: that it is not very common the use
of gsub over a fixed string.


--
Markus