lua-users home
lua-l archive

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


Hello all,

    Why not use --]] or ]]-- to end? Like /* and */. Ex:
--[[    ...    ]]-- or
--[[    ...    --]]

    As we are in suggestion time, i will make my one. Can you guys add range
operator? To use like:

    for x in 0..10 do print(x) end or
    for x in 'A'..'Z' do print(x) end

    Of course the .. need be other letters/signs or we need to change the
concat operator, because it is "..".
    Perhaps the best is the word "to":

    for x in 0 to 10 do print(x) end, y = 0 to 10 or y = { 0 to 10 } --
equal y = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }

    This is very useful, really save time.

    Other possible uses:

    z = { "a", "hello", "world", "z" }
    for k in z do
        if k in "a" to "z" then
            print("k (" .. k .. ") in range!");
        else
            print("k (" .. k ..") not in range!");
        end
    end

                                                            The God's Peace,


Leandro.

----- Original Message -----
From: <RLake@oxfam.org.pe>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Thursday, November 27, 2003 7:20 PM
Subject: RE: On the subject of Lua's grammar... --[[ ]]


> Nick Trout didn't think he'd be saying this, but:
> > what about the way it works in Perl?
>
> > e.g. <<END;
>
> > I can put anything I want here until my own delimiter is met...
>
> > END
>
> Actually, I think this comes from the Unix shell, even before Perl. It
> is also more or less the strategy used by MIME. However, it can also lead
> to obscure errors, and it is difficult to implement reliably in a code
> generator.
>
> I would actually suggest something much simpler: leave --[[, [[ and ]] as
> they are, except
> that they are only recognized if they are the first characters of a line,
> or perhaps
> the first non-whitespace characters.
>
> That does not allow an "arbitrary" string, but it would certainly solve
> all of my
> problems with accidental closing by a[b[j]]; I can probably remember not
> to
> write that as:
>
> a[b[
> ]]
>
> :)
>
> This would probably mean changing the semantics of long strings [[ ]] yet
> again,
> so that both the first and the last line end are deleted. Oh, well.
>