[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string.gsub (Lua 5.1.1)
- From: "Leo Razoumov" <slonik.az@...>
- Date: Mon, 6 Nov 2006 16:37:40 -0500
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--