lua-users home
lua-l archive

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

Luiz Henrique de Figueiredo wrote:
Yes, I can see myself spending time tracking down such a thing. I'll try to remember to use a semicolon when I add debug code like that:

function test2()
This code does not compile: "return" must be the last statement in the block.
So you need to use this instead: "do return end". No semicolon is needed.

Yes, believe it or not, I checked that it did NOT compile before posting it!

What I was trying to say was that if I used a semicolon there, the compiler would notice that I was attempting to run code beyond the 'return', so I would not reach the point of being surprised by the behavior. For some reason it felt more natural to remember to add a semicolon (and then fix it after it fails to compile) than to remember the 'do return end' construct.

These kinds of cross-line parsing issues don't come up too often for me. When I want to continue something on the next line, I just make sure that an expression or statement is incomplete so that more text must be read. But 'return' can appear with or without a following expression, so that's a case where I need to be more careful. David's post was a good reminder.


The information contained in this email transmission may contain proprietary and business sensitive information. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. Unauthorized interception of this e-mail is a violation of law. If you are not the intended recipient, please contact the sender by reply email and immediately destroy all copies of the original message.

Any technical data and/or information provided with or in this email may be subject to U.S. export controls law. Export, diversion or disclosure contrary to U.S. law is prohibited. Such technical data or information is not to be exported from the U.S. or given to any foreign person in the U.S. without prior written authorization of Elbit Systems of America and the appropriate U.S. Government agency.