anoma / juvix

A language for intent-centric and declarative decentralised applications
https://docs.juvix.org
GNU General Public License v3.0
442 stars 54 forks source link

Generalize import syntax #2819

Closed janmasrovira closed 1 week ago

janmasrovira commented 3 weeks ago

This pr introduces two enchancements to import statements:

  1. They can have using/hiding list of symbols, with a behaviour analogous to the open statement.
  2. They can be public. When an import is marked as public, a local module (or a series of nested local modules) is generated like this:
    import A public;
    -- equivalent to
    import A;
    module A;
      open A public;
    end;

    It is easier to understand when there is an alias.

    import A as X.Y public;
    -- equivalent to
    import A;
    module X;
      module Y;
        open A public;
      end;
    end;

    Public imports are allowed to be combined with using/hiding modifier and open statements with the expected behaviour.