Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 9101911

Browse files
authored
Add some on imports/exports
1 parent 88a317e commit 9101911

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

proposals/gc/Overview.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ Alternatively, foreign references could be typed. For example, introduce another
412412
```
413413
Here, the name is just a string whose meaning depends on the embedder (for example, it could embed its own domain-specific type algebra into strings). Casts are possible between different foreign types, but whether they succeed is up to the embedder.
414414

415+
An even nicer alternative may be to not have any internal means to define foreign types altogether, but instead require them to be [imported](import-and-export) as "host types", analogous to host functions. The host environment would then define a suitable set of types, and probably an API enabling the user to define their own additional types (including a subtype relation between them).
416+
415417

416418
### Function References
417419

@@ -569,7 +571,15 @@ That would require constraining the ability of implementations to reorder or ali
569571

570572
### Import and Export
571573

572-
Types can be exported from and imported into a module.
574+
Types can be exported from and imported into a module:
575+
```
576+
(type (export "T") (type (struct ...)))
577+
(type (import "env" "T"))
578+
```
579+
580+
Imported types are essentially parameters to the module.
581+
As such, they are entirely abstract, as far as compile-time validation is concerned.
582+
The only operations possible with them are those that do not require knowledge of their actual definition or size: primarily, passing and storing references to such types.
573583

574584
TODO: The ability to import types makes the type and import sections interdependent.
575585

0 commit comments

Comments
 (0)