fmease / lushui

The reference compiler of the Lushui programming language
Apache License 2.0
7 stars 0 forks source link

Path hanger `extern` instead of crate declarations #49

Closed fmease closed 3 years ago

fmease commented 3 years ago

Remove crate declarations (crate my-lovely-library) from the language and replace them by paths beginning with the path hanger external crates extern being a new keyword (extern.my-lovely-library).

Conceptually, we now have two roots in the module system: crate for the current crate being compiled(…) and crates for all the --linked library dependencies. For the purpose of documentation, let me inform you that before, we only had one – crate – and dependencies would be mounted into this single tree with duplicate crate declarations linking to the identical crate.

Motivations

Example

Currently

crate awesome
use awesome.Alpha

Beta: Type = Alpha Type

module sub =
    use crate.awesome

    gamma: … = awesome.stuff 0

module mu =
    module nu =
        crate awesome

        X: Type = awesome.f …

Then

use extern.awesome.Alpha

Beta: Type = Alpha Type

module sub =
    gamma: … = extern.awesome.stuff 0 ;; or `crate.awesome.stuff`

module mu =
    module nu =
        X: Type = extern.awesome.f … ;; or `crate.`…
fmease commented 3 years ago

Closed in #99.