Skip to content

Feature: Import System #7

Description

@ansurfen

Implement a flexible and conflict-resilient import system with support for multiple styles, name aliasing, and name conflict detection.

// math.hl
pub fn add(a: num, b: num) => $a + $b

pub fn mul(a: num, b: num) => $a * $b
// utils.hl
import "math" as m
import * from "math" // ❌ Error: name conflict
import { mul } from "math"

pub fn add(a: num, b: num) => m.add($a, $b)
pub fn mul               // ❌ Error: name conflict with imported `mul`

// Invalid syntax examples
import { mul as m } from "math"      // ❌ Error
import * as m from "math"           // ❌ Error

// Valid workaround
import { mul as ml } from "math"
pub fn mul(a: num, b: num) => ml($a, $b)
// main.hl
import "math"
import * from "utils"
import "math" as m
import { add as a } from "math"

echo add(1, 2) // utils's
echo math.add(1, 2) m.mul(1, 2) a(1, 2)

Export Table:

math.add math.mul
add (utils.add) mul (utils.mul)
m.add m.mul
a -> math.add

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions