Code blocks

A code block is enclosed by the begin and end keywords. Let's examine what the abstract syntax tree looks like.

The head node just contains a block symbol. When there are multiple lines in the block, the abstract syntax tree also includes line number nodes. In this example, there is a LineNumberNode with line 2 preceding the first call to println. Likewise, there is another LineNumberNode with line 3 preceding the second call to println. The LineNumberNode nodes do not do anything, but they are useful for stack traces and debugging.

Get Hands-On Design Patterns and Best Practices with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.