kyleect / locks

A toy language branched from Lox to learn language implementation and tooling. Forked from loxcraft
https://kyleect.github.io/locks/#/docs
MIT License
0 stars 0 forks source link

Modules #5

Open kyleect opened 8 months ago

kyleect commented 8 months ago

Imports

File path

import {} from './path/to/module';
from './path/to/import' import {};

Class/module path

import {} from path.to.module;
from path.to.module import {};

Exports

export var foo = "";
export fun name() {}
export class Example {}
kyleect commented 6 months ago
// @package/utils.locks

import third_party_lib::Thing;
import @std::http::{Request, Response};
import @package::Foo;

// This becomes the module and import path of  @package::utils::sum;
export fn sum (a, b) { return a + b; }
kyleect commented 6 months ago

One issue to think about are side effects when importing. Locks right now allows all types statements in locks files. This creates side effects when you import other locks files.

kyleect commented 6 months ago

Another question would be what module/import path system would be used? Declared package paths like java, relative file system paths like node, named/scoped packages like node, namespaces like c#