Skip to content

Change import syntax to allow for importing URIs

Yorick Peterse requested to merge change-import-syntax into master

This changes the import syntax from this:

import foo::bar::(A, B)

To this:

import 'foo/bar' (A, B)

This is done in preparation for Inko's upcoming package manager (#225 (closed)), which will introduce URI imports such as this:

import 'gitlab.com/inko-lang/json/v0' (Parser)

By using strings for import paths we don't restrict package URIs to names that are valid identifiers. Import paths require single quotes so we don't have to deal with double quoted string escape sequences, and so people stop bike shedding about which quote to use.

As part of this change the syntax for importing symbols is also changed a bit: they now appear in parentheses separate from the path, and parentheses are always needed. So instead of this:

import std::stdio::STDOUT
import std::process::(sleep)

You now write this:

import 'std/stdio' (STDOUT)
import 'std/process' (sleep)

Changelog: changed

Merge request reports