CharlyCst / zephyr

A Programming Language built for WebAssembly
https://charlycst.github.io/zephyr-playground/
10 stars 0 forks source link

Allow host function import #88

Closed CharlyCst closed 3 years ago

CharlyCst commented 3 years ago

What We want to allow runtime packages to import functions from the host environment, this functionality is strictly restricted to runtime packages.

Why In WebAssembly, importing functions is the only way to interact with the host environment.

However, we want to do things the right way: importing functions is limited to runtime packages to separate host-dependent code and functionality from the "application layer". In the future, runtime interfaces will further improve portability, by encapsulating host specific capabilities.

How We will add a new top-level declaration to define imports, which will look like:

pub import open_file(filename: String): i64 as open

The syntax is given by:

import -> "pub"? "import" IDENTIFIER "(" parameters ? ")" result ( "as" identifier )? ";"