Skip to content

Modules

Julius Paffrath edited this page Jul 1, 2026 · 9 revisions

Introduction

No one wants to write code multiple times, right? Jask allows the definition of modules, a jask file containing code, which can be imported in other jask scripts:

; file myLib.jask
function aVeryUsefullFunction()
    return "I am coming from a module!"
end

This file can now be imported in another script:

; file myScript.jask
use "myLib.jask" as myLib

print(myLib::aVeryUsefullFunction()

Note that you can choose the identifier for an imported module freely. It is recommended to use an identifier, which is recognizable and meaningful for your purposes.

jask standard libraries jcore

Jask consists not only of the interpreter, but also of a collection of helpful functions known as jcore. Jcore bundles a lot of common functionality, which is purely written in jask. It is meant as a demonstration of jasks capabilities and features. If you have implemented a usefull feature, help expanding jcore via a pull request!

Encapsulation

Global variables in modules are not accessible from scripts importing the module. Structs, however, are globally accessible.

Clone this wiki locally