Skip to content

Latest commit

 

History

History
111 lines (72 loc) · 1.87 KB

reference.md

File metadata and controls

111 lines (72 loc) · 1.87 KB

Sol Language Reference

Table of Contents

  1. Variables and Constants
  2. Control Flow
  3. Functions
  4. Standard Library

1. Variables and Constants

Declaration

Variables and constants in Sol are declared using the store keyword followed by the variable name and optional type annotation.

Example:

store name = "John"
store mul age = 30

Assignment

Assignment in Sol is performed using the = operator.

Example:

name = "Alice"
age = 25

2. Control Flow

If-Else Statements

Sol supports conditional execution using if-else statements.

Example:

if (condition) then
  // code to execute if condition is true
else
  // code to execute if condition is false
end

Loops

Sol provides for and while loops for iterative execution.

Example:

for (i = 0; i < 10; i++) do
  // code to execute in each iteration
end

3. Functions

Declaration

Functions in Sol are defined using the fn keyword followed by the function name and parameter list enclosed in parentheses ().

Example:

fn add(x, y) do
  return x + y
end

Invocation

Functions are invoked using the function name followed by the argument list.

Example:

result = add(10, 20)

4. Standard Library

Sol provides a standard library with built-in functions and modules for common tasks.

IO Module

The IO module provides functions for input and output operations.

Example:

import "io"
io.print("Hello, World!")

Math Module

The Math module provides functions for mathematical operations.

Example:

import "math"
result = math.pow(2, 3)

This reference document provides an overview of the core features and functionalities of the Sol language. For more detailed information, refer to the documentation and examples provided.