[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Lua 5.2.0 (beta-rc2) now available
- From: dcharno <dcharno@...>
- Date: Wed, 22 Jun 2011 11:17:14 -0400
On Jun 22, 2011, at 10:50 AM, James Graves <email@example.com> wrote:
> David Kastrup <firstname.lastname@example.org> wrote:
>> Alexandre Rion <email@example.com> writes:
>>> I also think that labels should be per block.
>> 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
Your suggestions might be a good idea, but the language shouldn't enforce them; thats what coding standards and code reviews are for. There is a good comment about this in PIL, something to the effect "Lua does not set policy. Lua provides powerful mechanisms for developers to implement the policies that best suit them."