lua-users home
lua-l archive

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


David Kastrup <dak@gnu.org> wrote:
> Alexandre Rion <gaumerie@hotmail.com> writes:
>
>> I also think that labels should be per block.
>
> +1
>
> Local variables are per block.  This makes it possible to have
> self-contained syntactical entities with minimal outside interaction.
> function-local labels break this concept, and it is not clear to me how
> this would affect label/goto outside of functions.

I think the one-label-per-function restriction is fine.

If your function is soooo big that you're losing track of what labels
you've been using, then you've got other problems.  Having unique
labels in each function makes it easier for me to read and understand
your code.

I would like to encourage all developers to:

A) Use 'goto' sparingly, of course.  Error handling and a 'continue'
replacement are acceptable to me.  However, if a little
re-organization would allow you to use some other control structure,
that is preferred.

B) Put as much thought into naming labels as you would naming local
variables.  Please use descriptive names, such as ::retry_read::
instead of just ::retry:: and ::skip_blank_line:: instead of
::continue::, to draw from some recent examples.

James Graves