lua-users home
lua-l archive

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


On 9/2/2014 4:17 AM, Dirk Laurie wrote:
2014-09-01 19:14 GMT+02:00 Luiz Henrique de Figueiredo:
A label does not need any other punctuation. In particular,
::continue::end is legal without an intervening spaces.

Why are you surprised?

I've been automicallly either putting a label on its own line or at worst
coding a space ever since the goto statement was introduced.
Yesterday I mistyped, so there was no space. When I noticed the
omission later, it made me wonder why there was no error.

There are lots of other non-standard ways of writing ::label:: that will pass the parser -- it's still unambiguous to the parser. A look at llex and lparser would make the possibilities obvious, for example (using Lua 5.2):

::
--comment
label
--comment
::

Etc. But most people would stick to normal usage. :-)

Editors with syntax highlighting should colour your bit of code correctly, giving users unambiguous visual feedback. Editors based on Scintilla (SciTE, Notepad++, Geany, etc etc) does this, or should be doing this, at least SciTE does (but not the above example, only a reasonable 'sane' subset).

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia