[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: String confusion
- From: Craig Barnes <craigbarnes85@...>
- Date: Fri, 28 Sep 2012 14:14:45 +0100
On 28 September 2012 12:38, David Collier <myshkin@cix.co.uk> wrote:
>
> In http://www.lua.org/pil/20.html
>
> I see "A program can create string literals and concatenate them. But it
> cannot extract a substring, check its size, or examine its contents"
>
> and yet if I have
>
> s="123"
> print( #s )
>
> I print 3
>
> How is this not a contradiction?
>
The full paragraph you quoted from reads:
"The power of a raw Lua interpreter to manipulate strings is quite limited.
A program can create string literals and concatenate them. But it cannot
extract a substring, check its size, or examine its contents. The full power
to manipulate strings in Lua comes from its string library."
Unless I'm mistaken, using the length operator (#) on a string just calls
string.len() via metamethod, which is indeed part of the string library and
not the "raw Lua interpreter".
I guess it's fair to say that the use of the word "program" without the
surrounding context is a little ambiguous though.