lua-users home
lua-l archive

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


On Sun, Dec 19, 2010 at 07:10:00PM +0200, David Kastrup wrote:
> Dirk Laurie <dpl@sun.ac.za> writes:
> 
> >>From the Reference Manual, description of the function string.byte:
> >
> > [[
> >     Returns the internal numerical codes of the characters 
> >     s[i], s[i+1], ···, s[j]
> > ]]
> >
> > What better proof do we need that s[i] means the character 
> > corresponding to the i-th byte of the string s?  If not (yet)
> > in the Lua language, then at least in the terminology used by
> > the author of the reference manual?
> 
> That kind of logic leads to Cobol.

The logic is as follows:

1. There are many situations in which a concise notation for
    the i-th character of a string s is useful, including the
    description of what string.byte does.
2. The notation s[i] for that purpose is so universally 
    understood that it is used without further ado in the 
    Lua Reference Manual.
3. It would therefore not be an obscure notation in the Lua
    language itself.

I find the reference to Cobol totally incomprehensible.
Cobol is a language that over-emphasizes the use of English 
words rather than notation based on symbols, thus:

ADD SALARY_INCREMENT TO CURRENT_SALARY GIVING NEW_SALARY

It is Cobolic to write "string.sub(i,i)" rather than "s[i]".

Dirk