oxidic / oxido

Oxido is a statically typed interpreted programming language for making CLI tools and scripts.
https://oxido.megatank58.xyz
MIT License
8 stars 3 forks source link

Module System #12

Open simon-curtis opened 1 year ago

simon-curtis commented 1 year ago

I was curious as to how you're going to do modules? I've looked in a lot of places for inspiration, but cannot find any solid references

megatank58 commented 1 year ago

I haven't started work on modules yet however there are a two approaches I've been considering:

String imports with global merge

The syntax would be something like import "./util.oxi" and at an external level it would act as merging the two files together, somewhat like golang does.

The rust-y approach

This would need bit of time to implement for my language simply because such syntax isn't really used anywhere else but use abc::x would look nice, there would be a need for a new Module map which would have keep track of these additional files and their exported values.

Before either of the approaches I'm adding the . operator so that accessing exported values is possible

simon-curtis commented 1 year ago

Have you seen how zig does it? It's quite nice. Have only seen it used on coding streams so far, not really had a chance to learn how it works properly.

I'm worried about how I'm going to implement it in my language as it seems to either be good for the developer or good for the compiler... never both 😕