Skip to Main Content
Think Julia
book

Think Julia

by Ben Lauwens, Allen B. Downey
April 2019
Beginner content levelBeginner
295 pages
5h 48m
English
O'Reilly Media, Inc.
Content preview from Think Julia

Chapter 21. Debugging

When you are debugging, you should distinguish among different kinds of errors in order to track them down more quickly:

  • Syntax errors are discovered by the interpreter when it is translating the source code into byte code. They indicate that there is something wrong with the structure of the program. Example: Omitting the end keyword at the end of a function block generates the somewhat redundant message ERROR: LoadError: syntax: incomplete: function requires end.

  • Runtime errors are produced by the interpreter if something goes wrong while the program is running. Most runtime error messages include information about where the error occurred and what functions were executing. Example: An infinite recursion eventually causes the runtime error ERROR: StackOverflowError.

  • Semantic errors are problems with a program that runs without producing error messages but doesn’t do the right thing. Example: An expression may not be evaluated in the order you expect, yielding an incorrect result.

The first step in debugging is to figure out which kind of error you are dealing with. Although the following sections are organized by error type, some techniques are applicable in more than one situation.

Syntax Errors

Syntax errors are usually easy to fix once you figure out what they are. Unfortunately, the error messages are often not helpful. The most common messages are ERROR: LoadError: syntax: incomplete: premature end of input and ERROR: LoadError: syntax: unexpected ...

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

Practical Julia

Practical Julia

Lee Phillips
Getting Clojure

Getting Clojure

Russ Olsen
Learning Go

Learning Go

Jon Bodner

Publisher Resources

ISBN: 9781492045021Errata PageSupplemental Content