lua-users home
lua-l archive

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


On Thu, Apr 30, 2009 at 7:31 AM, David Manura <dm.lua@math2.org> wrote:
> The question of to inject or not to inject into the standard
> table/string tables is a common one[1-3] in the standard library
> proposals.

Generally a bad idea, which we know from the people who do
'programming in the large'. (The C++ community can seem a bit
obsessive about this issue, but they sometimes maintain millions of
lines of code.)  I don't like how luaex puts things in os, for
instance.

But I could not resist the temptation to insert extra string methods,
but _optionally_. This happens with a slapdash require 'pl' but
otherwise needs an explicit pl.string.import() call. The basic
principle is not to change the semantics of any existing methods.
Given these restraints I think it's fairly safe (one can of course do
stringx = require 'pl.string' and work with things explicitly)

> Perhaps a way around it is the "MethodChainingWrapper".[4]

Definitely a useful technique!  Although perhaps also achievable with
traditional subclassing (a StringEx type)

steve d.