IMPORT

Imports definitions from another L4 file or library.

Syntax

IMPORT filename
IMPORT `hyphenated-name`

Purpose

IMPORT brings type definitions, functions, and values from another L4 source file into the current file's scope.

Examples

Example file:

-- IMPORT keyword examples

-- Importing Standard Libraries

-- Import math library for mathematical functions
IMPORT math

-- Use functions from math library
#EVAL exp 1
#EVAL sqrt 16
-- Using Imported Functions

-- Math functions become available after import
GIVEN r IS A NUMBER
circleArea r MEANS 3.14159 TIMES r TIMES r

#EVAL circleArea 5

-- Import Syntax Notes

-- For hyphenated library names, use backticks:
-- IMPORT `some-library`

-- Multiple imports can appear in sequence:
-- IMPORT math
-- IMPORT daydate

-- Libraries are resolved from the jl4-core/libraries/ directory
-- or relative to the current file

Importing Core Libraries

IMPORT math
IMPORT daydate
IMPORT currency

Importing Hyphenated Names

Use backticks for names containing hyphens:

IMPORT `legal-persons`
IMPORT `excel-date`

Importing Local Files

IMPORT myhelpers
IMPORT utils

Available Libraries

L4 includes several standard libraries:

Library Description
prelude Core functions (auto-imported)
math Mathematical functions
daydate Date calculations
excel-date Excel date compatibility
currency Currency handling
legal-persons Legal entity types
coercion Type conversions

Import Resolution

  1. Prelude is automatically imported in all files
  2. Library names resolve to jl4-core/libraries/
  3. Relative names resolve to the current directory

See Also