Skip to Content
Beginning Lua Programming
book

Beginning Lua Programming

by Kurt Jung, Aaron Brown
February 2007
Beginner
672 pages
15h 34m
English
Wrox
Content preview from Beginning Lua Programming

Chapter 6. Handling and Avoiding Errors

Program correctness matters on every count, from user acceptance and trust to the downstream consequences of program output. In this chapter, you learn about the following:

  • The kinds of errors that can occur in your programs

  • Lua's mechanisms for handling errors

  • Techniques to avoid program errors

  • Techniques to locate program errors

Along the way, you'll become familiar with Lua's I/O library, which is included in some of the examples.

Kinds of Errors

Some flaws can turn up before a program is executed. These are compile-time errors, which Lua can find as it converts your source code into executable bytecode. Often these result from simple misspellings or typing slips as you edit your source code. Other flaws are more insidious—Lua recognizes them as syntactically correct so they make their way into the executable bytecode. These errors await discovery at run time, preferably by you during testing rather than by someone who's actually using a product after it's been released with the erroneous code.

Syntax Errors

Syntax refers to the way various language elements are allowed to fit together, completely independent from the meaning of those elements. A programming language like Lua is necessarily fussy about syntax, because source code expressed in it needs to translate unambiguously to bytecode, the instructions that Lua's virtual machine can deal with. During the 1960s (the renaissance era of modern programming languages) computer science practitioners ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Lua Quick Start Guide

Lua Quick Start Guide

Gabor Szauer
The Go Programming Language

The Go Programming Language

Alan A. A. Donovan, Brian W. Kernighan

Publisher Resources

ISBN: 9780470069172Purchase book