Neon
← Back to Parallel programmingNext: Advanced features →

Modules

Modules help organize code into namespaces using a prefix (e.g., ModuleName~function).


1. Creating a Module

Example: Math Module

# Define functions in the Math module
function Math~add(a, b) do
    return (a + b)
end

function Math~sub(a, b) do
    return (a - b)
end

# Use the module
result = Math~add(5, 3)  # → 8
result = Math~sub(10, 4) # → 6

2. The loadNamespace Function

Loads all objects from a module without the prefix into the current scope.

Example

# Define a module
function Geometry~circleArea(r) do
    return (3.14159 * r ** 2)
end

# Load the module
loadNamespace("Geometry")

# Now use functions without prefix
area = circleArea(5)  # → 78.53975

Important Notes


3. The import Keyword

Executes the contents of a .ne file (or AppVar on TI-EZ80).

Syntax

import "filename"  # Without .ne extension

Example

# File: math.ne
function add(a, b) do
    return (a + b)
end

# Main program
import "math"
print(add(2, 3))  # → 5

On TI-EZ80

import "MYPROGRAM"  # AppVar name (no extension)

Notes


← Back to Parallel programmingNext: Advanced features →