Definitions

This topic is meant to document definitions in Pile

Overview

In the Pile programming language, a definition is a constant value bound to a name which is computed at the time of its creation.

Creating a Definition

To create a definition in Pile, use the def keyword followed by the name of the definition and end keyword to mark the end of the definition.

Syntax:

def <NAME>
<CONSTANT>
end

<CONSTANT> can be any expression that results in a value on top of the stack to be associated with the definition's name.

Code examples

Here's an example demonstrating a simple definition that stores the result of 1 + 1:

def ONEPLUSONE 1 1 + end

ONEPLUSONE println
# Output: 2

Here's another example of a definition that stores π:

def PI 3.14159265359 end

Note that you can input any code inside the definition's block as long as there is a value on top of the stack produced by the expression to be bound to the name.