Skip to content

Commit

Permalink
document leo constants
Browse files Browse the repository at this point in the history
  • Loading branch information
collinc97 committed Nov 8, 2023
1 parent b80241e commit b278085
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion documentation/leo/03_language.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ program test.aleo {

## Layout of a Leo Program

A Leo program contains declarations of a [Program Scope](#program-scope), [Imports](#import)
A Leo program contains declarations of a [Program Scope](#program-scope), [Constants](#constant), [Imports](#import)
, [Transition Functions](#transition-function), [Helper Functions](#helper-function), [Structs](#struct)
, [Records](#record),
[Mappings](#mapping), and [Finalize Functions](#finalize-function).
Expand Down Expand Up @@ -195,6 +195,7 @@ program hello.aleo {

The following must be declared inside the program scope in a Leo file:

- constants
- mappings
- record types
- struct types
Expand Down Expand Up @@ -223,6 +224,23 @@ program 0_foo.aleo; // invalid
program _foo.aleo; // invalid
```

### Constant

A constant is declared as `const {name}: {type} = {expression};`.
Constants are immutable and must be assigned a value when declared.
Constants can be declared in the global program scope or in a local function scope.

```leo
program foo.aleo {
const FOO: u8 = 1u8;
function bar() -> u8 {
const BAR: u8 = 2u8;
return FOO + BAR;
}
}
```

### Import

You can import dependencies that are downloaded to the `imports` directory.
Expand Down

0 comments on commit b278085

Please sign in to comment.