lua-users home
lua-l archive

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


On 11/6/06, Shmuel Zeigerman <shmuz@actcom.co.il> wrote:

API *is* the manual. The manual (not the source code!) is the only
definitive authority with regards to the API. What you suggest is not
rewording, it is *change*, since number of matches and number of
substitutions are totally different things.


I would *stongly* disagree. The source code and the manual both
provide insights into API. In case they do not much each other
neither of the two is a definitive winner.
For string.gsub(...)  I vote to corrent the manual!

To give you an example, I find it very handy handy to count "/" chars
in a path using the following idiom:

path= "/many/nested/directories"
_,n= path:gsub("/",{})  -- n counts "/" chars. (n == 3 here)

On the other hand, according to the manual, "n" should be zero since
no actual substitutions were made.

Also, please, keep in mind that changing a manual does not break
existing code while changing the core Lua could potentially break
existing code in very subtle and unpredictable ways.

--Leo--