Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe separate the compilation schemes #517

Closed
wants to merge 1,334 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
1334 commits
Select commit Hold shift + click to select a range
c1c2ea4
Remove tests/bugs (#1019)
nomeata Jan 17, 2020
2c5ab97
remove poly arg from Control.Promise
crusso Jan 17, 2020
0fda049
remove option from AsyncT scope
crusso Jan 17, 2020
fb76984
remove @ from id
crusso Jan 17, 2020
ff625b0
Merge pull request #1112 from dfinity-lab/claudio/scoped-await-sweet-…
crusso Jan 17, 2020
aac015e
Create table entries only on demand (#1124)
nomeata Jan 17, 2020
25521e6
refactor
crusso Jan 17, 2020
5eee84a
nix: start using niv to manage external sources (#1118)
basvandijk Jan 17, 2020
cb50163
Nix: Do not pull separate nixpkgs for llvm (#1132)
nomeata Jan 17, 2020
d4270be
merge with master
crusso Jan 17, 2020
fe78a2e
add test output file; delete commmented out code
crusso Jan 18, 2020
5111672
Make PrincipalId abstract (#1128)
nomeata Jan 18, 2020
de3f449
Merge branch 'master' into claudio/scoped-await-sweet-fix
crusso Jan 18, 2020
6499a7a
Stdlib: Reorganize build, test and nix setup (#1135)
nomeata Jan 19, 2020
315000f
Update darwin packer (#1133)
nomeata Jan 20, 2020
486176f
Merge branch 'master' into claudio/scoped-await-sweet-fix
crusso Jan 20, 2020
8d1de64
remove tests deleted from master
crusso Jan 20, 2020
d1594d2
remove debug residue (oops)
crusso Jan 20, 2020
0dc5519
Bump libtommath to release v1.2.0 (#1138)
ggreif Jan 20, 2020
2e604b4
implement query restrictions
crusso Jan 20, 2020
735d1c7
Bump drun (#1141)
nomeata Jan 20, 2020
8f1ecbc
refine async_cap to allow throw/try/catch from queries
crusso Jan 20, 2020
5c6130d
missing file
crusso Jan 20, 2020
deeb0ab
Merge branch 'master' of github.com:dfinity-lab/motoko into joachim/c…
nomeata Jan 21, 2020
69cd514
More constant expressions: variables, blocks (#1113)
nomeata Jan 21, 2020
9669c50
Constant objects and modules (#1121)
nomeata Jan 21, 2020
a58f64b
Merge branch 'master' of github.com:dfinity-lab/motoko into joachim/c…
nomeata Jan 21, 2020
a0f0d1f
fix doc simplifying sugar and updating examples; address joachims sug…
crusso Jan 21, 2020
5f3c1d8
unbreak the build
crusso Jan 21, 2020
9b3a03b
Stores all paths in the ide server as absolute paths (#1143)
kritzcreek Jan 21, 2020
5ce300a
fix nit
crusso Jan 21, 2020
73e82da
Stdlib: Re-export from prim, not redefine (#1144)
nomeata Jan 21, 2020
216ec9b
improve await error message by naming async scopes (withoug affecting…
crusso Jan 21, 2020
210943e
Move docTable module from stdlib to PX (#1147)
nomeata Jan 21, 2020
1aeaf83
Make hydra comment with the performance delta (#1151)
nomeata Jan 22, 2020
3f13d92
Backend: Resolve constant DotE expressions (#1145)
nomeata Jan 22, 2020
aef5f21
Fix IDL encoding of positive ints (#1149)
nomeata Jan 22, 2020
f860916
perf-delta: Include one decimal point (#1152)
nomeata Jan 22, 2020
0cf39d4
Require imports to be specified without file extension (#1130)
kritzcreek Jan 22, 2020
97f96c8
use $ not @ as scope parameter prefix to avoid clashes with priviledg…
crusso Jan 22, 2020
76b8dad
Merge branch 'master' into claudio/scoped-await-sweet-fix
crusso Jan 22, 2020
0ad74c9
missing test output
crusso Jan 22, 2020
a7c50d1
Fix #945: Do not discard non-typed code (#1146)
nomeata Jan 22, 2020
6105495
missing test output
crusso Jan 22, 2020
8228aa4
QC: inter-actor message sends and encoding tests (#1094)
ggreif Jan 22, 2020
e0ed781
merge with master
crusso Jan 22, 2020
fc09987
Backend: Remove code for local actors (#1140)
nomeata Jan 22, 2020
0709c75
merge with master
crusso Jan 22, 2020
9ab88e3
Merge pull request #1056 from dfinity-lab/claudio/scoped-await-sweet-fix
crusso Jan 22, 2020
9fbcc97
QC: make sure we have 2 OS threads (#1153)
ggreif Jan 22, 2020
b7def7e
bump dfinity
ggreif Jan 23, 2020
bc0146e
accept tests
ggreif Jan 23, 2020
a57d239
Merge pull request #1155 from dfinity-lab/gabor/bump-dfinity
crusso Jan 23, 2020
b4c4289
bump common (#1157)
ggreif Jan 23, 2020
69f248b
ic-stub: Remove ability to create canisters (#1154)
nomeata Jan 24, 2020
ae9525c
Bump drun (#1158)
nomeata Jan 25, 2020
b4fd842
Apply suggestions from code review
nomeata Jan 25, 2020
e47932d
Merge branch 'master' of github.com:dfinity-lab/motoko into joachim/c…
nomeata Jan 25, 2020
e9997d6
GC: Only traverse mutable static heap objects (#1139)
nomeata Jan 25, 2020
437e6ec
Try reducing the drun extra batches (#1159)
ggreif Jan 25, 2020
da5f546
Merge branch 'master' into joachim/const-static
nomeata Jan 25, 2020
daad463
Create static heap objects for constant values on demand (#1123)
nomeata Jan 25, 2020
6c46355
update DFX-Interface (#1148)
chenyan-dfinity Jan 25, 2020
100a9c8
Add test/compare-perf.sh script (#1160)
nomeata Jan 27, 2020
398079a
Avoid clang warning (#1161)
ggreif Jan 27, 2020
ad26233
Enable full async/await on IC target (Requires PR #1056) (#1142)
crusso Jan 27, 2020
7d223e2
resolve relative imports for --print-deps (#1165)
chenyan-dfinity Jan 28, 2020
a6dd07e
Refactor stdlib reference generation (#1166)
nomeata Jan 29, 2020
3236ff9
fix correctness bug in Buf
matthewhammer Jan 30, 2020
3f1b4e5
add regression test for bug fix
matthewhammer Jan 30, 2020
9af8a98
fix test, extend test; another bug fix
matthewhammer Jan 30, 2020
c013121
Merge pull request #1171 from dfinity-lab/buf-fix
matthewhammer Jan 30, 2020
1fe00c9
Claudio/syntax errors (#1167)
crusso Jan 30, 2020
5d6ac6c
stlib/list: Avoid local closures (#1169)
nomeata Jan 30, 2020
0b80a40
Stdlib: More bug fixes in `Buf` (#1177)
matthewhammer Jan 31, 2020
c178e04
Claudio/issue 827 (#1172)
crusso Jan 31, 2020
9a0fd63
Simpler parameter desugaring (#1181)
nomeata Feb 3, 2020
5bea22c
desugar oneway bodies to `ignore (async _ : async ())` (#1179)
crusso Feb 4, 2020
20df622
Makes the resolve logic more lenient around extensions (#1184)
kritzcreek Feb 5, 2020
b937038
Stdlib/hash: Cleanup (#1170)
nomeata Feb 5, 2020
d26205b
stdlib: Document and format option (#1186)
nomeata Feb 5, 2020
681e06c
Prelude: Only define functions (#1187)
nomeata Feb 6, 2020
4bf70d6
Fix for bad type annotation after cps conversion (#1190)
crusso Feb 10, 2020
22e6f9f
fix interpreters to avoid second trip through scheduler in high-level…
crusso Feb 10, 2020
3117224
Claudio/check ir perf (#1192)
crusso Feb 11, 2020
66b9e36
Fix broken desugaring of var decls (#1191)
crusso Feb 11, 2020
68bdce7
disable packager
Feb 11, 2020
d8ef428
Merge pull request #1194 from dfinity-lab/INF-975
pikajude Feb 11, 2020
d3998be
Remove mergify support for non-squash automerge (#1195)
nomeata Feb 11, 2020
7883956
nix/sources.json: upgrade nixpkgs to the latest master (#1189)
basvandijk Feb 13, 2020
b81ba4b
Automatically import on completion (#1198)
kritzcreek Feb 14, 2020
74dfa8c
Stdlib: add Nat/Int.min/max (#1205)
nomeata Feb 16, 2020
11ad557
Bug fix in tabulateVar (#1207)
enzoh Feb 17, 2020
c03786a
utf8 bug repro for issue #1208 (#1212)
crusso Feb 17, 2020
be2667f
filters out completions that would lead to self-imports (#1214)
kritzcreek Feb 18, 2020
05f41e1
Reports diagnostics at startup (#1215)
kritzcreek Feb 18, 2020
ea32767
RTS: Fix utf8 validation bug (#1213)
nomeata Feb 18, 2020
7ce3acc
update common (#1217)
pikajude Feb 18, 2020
3f9bb99
Backend: Implement eq on `Principal` (#1206)
nomeata Feb 18, 2020
9558500
Scans the passed package paths for .mo files (#1210)
kritzcreek Feb 19, 2020
0d827fe
Improve error messages for scoped awaits (#1221)
crusso Feb 19, 2020
b90fbc5
nix/haskell-packages: replace IFD with importing generated files (#1220)
basvandijk Feb 19, 2020
6245825
Test case: Bad error message with variant short-hand form (#1219)
nomeata Feb 20, 2020
d4abbae
Test runner: Check if `drun` and `ic-stub-run` are installed (#1216)
nomeata Feb 20, 2020
b1e6065
Drive-by improvements to README (#1225)
nomeata Feb 20, 2020
97e4f2b
Completions and auto-imports for canisters (#1222)
kritzcreek Feb 20, 2020
2fd8bbb
Separate diagnostics for beginning and end of scope (#1229)
crusso Feb 20, 2020
c09f7e1
Add principal type to IDL spec (#1211)
chenyan-dfinity Feb 20, 2020
004dfc5
Decide which tests to run by the availability of the embedders (#1227)
ggreif Feb 20, 2020
290534b
Refactor setup for generated nix files (#1223)
nomeata Feb 20, 2020
63a85d6
Bump nixpkgs, track upstream (#1226)
nomeata Feb 21, 2020
150e206
Nix: make decision about static linking only once (#1230)
nomeata Feb 21, 2020
25bb223
type argument infernce, first stab
crusso Feb 21, 2020
aa567d1
inference test
crusso Feb 21, 2020
b86d879
avoid looping; more examples
crusso Feb 22, 2020
476d7bc
RTS: Track canister lifecycle state machien
nomeata Feb 22, 2020
d285705
nix: specify a sha256 for fetching sources.nix (#1234)
basvandijk Feb 24, 2020
5dc2ad3
Some IDE robustness fixes (#1235)
kritzcreek Feb 25, 2020
7a262e5
RTS: Put hash list of objects into static memory (#1233)
nomeata Feb 25, 2020
fe5f3f3
more examples
crusso Feb 25, 2020
74f3e1d
Merge branch 'master' into claudio/inference
crusso Feb 25, 2020
540bdeb
Some more IDE fixes for the demo (#1236)
kritzcreek Feb 26, 2020
31aa7ae
Normalises file paths before sending them to the editors (#1237)
kritzcreek Feb 26, 2020
414317c
prelimary implementation of bimatching - todo mut arrays, constructor…
crusso Feb 26, 2020
5de6fc8
more changes
crusso Feb 26, 2020
ee8388e
special case inference for scoped monomorphic function to continue to…
crusso Feb 26, 2020
634202e
bound tests
crusso Feb 26, 2020
1b02361
Functorizes type pretty printing and hides stamps from IDE types (#1240)
kritzcreek Feb 27, 2020
25fe971
s/Running/Idle/g
nomeata Feb 27, 2020
198eff8
Merge branch 'master' of github.com:dfinity-lab/motoko into joachim/l…
nomeata Feb 27, 2020
604f05e
RTS: Track canister lifecycle state machine (#1231)
nomeata Feb 27, 2020
895efb9
refactor, add test output
crusso Feb 27, 2020
3dbde59
mo stuff
crusso Feb 27, 2020
1ba1252
Basic upgrade infrastructure (#1199)
nomeata Feb 27, 2020
12a027e
add scope violation test
crusso Feb 27, 2020
a658af3
add scope violation test
crusso Feb 27, 2020
4f0b457
INF-996 .github: Add action for updating niv-dependencies
knl Feb 20, 2020
e22eb8c
Merge pull request #1228 from dfinity-lab/INF-996-automate-dependency…
knl Feb 28, 2020
e93a3dd
## Changelog for common: (#1250)
dfinity-bot Feb 28, 2020
52b0e7b
nix/sources.json: update common for the nixpkgs upgrade (#1251)
basvandijk Feb 29, 2020
2341e70
merge with master
crusso Feb 29, 2020
3ca2ddf
reject instantiation at mut types
crusso Feb 29, 2020
f47f868
tests involving open types with bounded pars
crusso Feb 29, 2020
58e948b
nix: Track nixpkgs-unstable, not master (#1241)
nomeata Mar 1, 2020
4a9cc84
Nix: Fetch ic-stub from ic-ref repo (#1243)
nomeata Mar 2, 2020
b69a500
add test for invariance of mutable arrays
crusso Mar 2, 2020
53433be
fix typo
crusso Mar 2, 2020
4deb3ed
re-introduce rel eq args for efficient treatment of invariant constru…
crusso Mar 2, 2020
c03af44
remove straw man match implementation
crusso Mar 2, 2020
76ad47d
rename bimatch to bi_match etc
crusso Mar 2, 2020
05decaf
move Type.bi_match to mo_frontent/bi_match.ml
crusso Mar 2, 2020
94ed2e7
remove option from bi_match return type; all errors by exceptions
crusso Mar 2, 2020
6c21c13
.github: niv-updater-action v3 -> v4 (#1255)
knl Mar 3, 2020
e67ee97
exploit expectation in type argument inference
crusso Mar 3, 2020
4d9e2c1
reject T.Typ instantiations
crusso Mar 3, 2020
42e095a
merge with parent
crusso Mar 3, 2020
1e5e551
improved error messages & formatting, update test inference.mo and vi…
crusso Mar 3, 2020
94ec9a3
update comment
crusso Mar 4, 2020
2b4e9fe
ci-pr.nix: use the src.mergeBase input instead of base (#1261)
basvandijk Mar 4, 2020
d7cc6f2
factor CallE inference into separate function, called twice
crusso Mar 4, 2020
0adb42b
Bump ic-ref (#1264)
nomeata Mar 4, 2020
3e643b5
Remove winter from sources.json (#1263)
nomeata Mar 4, 2020
e0d70d8
take list of subtyping problems, not two lists; push defensive verifi…
crusso Mar 4, 2020
6d90675
Merge branch 'master' into claudio/inference
crusso Mar 4, 2020
025b78b
Auto-update: Do not update ic-ref (#1258)
nomeata Mar 4, 2020
2efb6f0
Merge branch 'master' into claudio/inference
crusso Mar 4, 2020
caa4490
Update src/mo_frontend/bi_match.ml
crusso Mar 4, 2020
7b39e11
Update src/mo_frontend/bi_match.ml
crusso Mar 4, 2020
029f35c
Update src/mo_frontend/bi_match.ml
crusso Mar 4, 2020
61efbbf
added (rough) mathematical spec of alg
crusso Mar 4, 2020
b27ca3b
formatting
crusso Mar 4, 2020
a5c0170
typos
crusso Mar 4, 2020
7b580ac
address review
crusso Mar 5, 2020
169a69c
Update test/fail/inference.mo
crusso Mar 5, 2020
a862a6f
## Changelog for common: (#1256)
nomeata Mar 5, 2020
be8497e
## Changelog for common: (#1267)
mergify[bot] Mar 5, 2020
58376ea
Merge branch 'master' into claudio/inference
crusso Mar 5, 2020
b9f7a80
Claudio/inference (#1242)
crusso Mar 5, 2020
71b3f98
Suppress inference for explicitly empty instantiations (#1265)
crusso Mar 5, 2020
2967ef5
## Changelog for common: (#1269)
dfinity-bot Mar 6, 2020
4aacf9d
Mergify: Auto-approve PRs by dfinity-bot (#1271)
nomeata Mar 6, 2020
49866f7
Bump drun (#1248)
nomeata Mar 6, 2020
a856438
Add Principal to IDL (#1268)
chenyan-dfinity Mar 6, 2020
7fcfb55
niv autoupdater: Only run once per day (#1270)
nomeata Mar 7, 2020
370d333
## Changelog for common: (#1272)
dfinity-bot Mar 7, 2020
ce76e60
## Changelog for common: (#1274)
dfinity-bot Mar 9, 2020
8cccfe2
fix bug in mo_to_idl (#1275)
chenyan-dfinity Mar 9, 2020
5608307
## Changelog for common: (#1277)
dfinity-bot Mar 10, 2020
4436275
update rts to decode principal (#1273)
chenyan-dfinity Mar 10, 2020
849cfba
Fix for unsorted recorded fields after pattern inference (#1278)
crusso Mar 10, 2020
6c14f08
Fix pretty printing of function types with scope parameters (#1281)
crusso Mar 11, 2020
bac0148
Bug fix: typo in async case of bi_match.ml (bad scope matching) (#1282)
crusso Mar 11, 2020
524f39d
## Changelog for common: (#1286)
dfinity-bot Mar 12, 2020
95ab2e9
Update niv-updater-action to v5 (#1285)
knl Mar 12, 2020
b68e97f
cosmetic change in compile_js (#1284)
chenyan-dfinity Mar 12, 2020
d6b8d0f
niv common: update c022ff9f -> c83d9681 (#1292)
dfinity-bot Mar 13, 2020
d9f081e
niv common: update c83d9681 -> 305dbe73 (#1297)
dfinity-bot Mar 17, 2020
3c2e396
inference revisions for rossberg (#1296)
crusso Mar 18, 2020
f0e729d
RTS: Create upgrade hooks also on drun (#1249)
nomeata Mar 18, 2020
995d15b
Stdlib: Call the module principal, not principalId (#1298)
nomeata Mar 19, 2020
3aef8bf
niv common: update 305dbe73 -> 32956d48 (#1300)
dfinity-bot Mar 20, 2020
8cf3b88
niv common: update 32956d48 -> aaaa0f66 (#1302)
dfinity-bot Mar 21, 2020
9e0e17e
fix: stdlib Array tabulateVar
matthewhammer Mar 23, 2020
210f5e9
regression test for fix
matthewhammer Mar 23, 2020
d8b1469
run.sh: Do not warn about missing ic-ref when doing perf tests (#1305)
nomeata Mar 24, 2020
5be8d80
IR.FreeVars: Fix stupid typo (#1306)
nomeata Mar 24, 2020
0b459e2
stdlib: Capitalize module names (#1307)
nomeata Mar 24, 2020
7ded9d7
niv common: update aaaa0f66 -> d696e4eb (#1310)
dfinity-bot Mar 25, 2020
a67695f
Design overview for stable variables and upgrade hooks (#1238)
rossberg Mar 25, 2020
74220d8
Bump ic-ref (#1309)
nomeata Mar 25, 2020
9e51529
niv common: update d696e4eb -> 24be014b (#1312)
dfinity-bot Mar 26, 2020
86c8fca
Applies ocamlformat to languageServer sources (#1308)
kritzcreek Mar 26, 2020
8ece631
Only add imports for capital module names (#1314)
kritzcreek Mar 27, 2020
c9dbf4c
Removes the completion template logic (#1313)
kritzcreek Mar 27, 2020
d5719a6
niv common: update 24be014b -> d0c1d2d5 (#1315)
dfinity-bot Mar 28, 2020
78660e1
niv common: update d0c1d2d5 -> 21396311 (#1318)
dfinity-bot Mar 31, 2020
958ebc7
fix syntax
matthewhammer Mar 31, 2020
546a04f
simplify code
matthewhammer Mar 31, 2020
9af8bad
Merge branch 'master' into matthew/array-fix
matthewhammer Mar 31, 2020
58b6241
Merge pull request #1303 from dfinity-lab/matthew/array-fix
matthewhammer Mar 31, 2020
1f9453c
niv common: update 21396311 -> 22f5d566 (#1321)
dfinity-bot Apr 2, 2020
d36dadc
Bump drun (#1328)
nomeata Apr 2, 2020
f882198
tests/perf: Include the QR in tests/perf (#1326)
nomeata Apr 2, 2020
7d1d615
tests.perf: Record gas numbers again (#1327)
nomeata Apr 2, 2020
b23c1d3
IR: Make notes record more abstract (#1325)
nomeata Apr 2, 2020
b68a5b3
construct.ml: Make var a spearate type from exp (#1330)
nomeata Apr 3, 2020
ac3dbb2
Peephole optimise eqz before if (#1331)
ggreif Apr 5, 2020
f07b5f9
Test suite: add prim.mo (#1332)
nomeata Apr 5, 2020
9e50a5e
Testsuite: static-call-redex (#1337)
nomeata Apr 6, 2020
661cec0
Check_ir: Check the const annotation (#1333)
nomeata Apr 6, 2020
72d92c9
An analysis pass for constness (#1334)
nomeata Apr 6, 2020
31e1d11
Compile: More disciplined detection of the TopLevel (#1335)
nomeata Apr 6, 2020
4125f41
Test case: capturing top-level variables in local function (#1342)
nomeata Apr 7, 2020
5b5b57f
Cleaning up Language Server interfaces (#1340)
kritzcreek Apr 7, 2020
36498aa
use ine Wasm instruction for integral not-equal (#1344)
ggreif Apr 7, 2020
1ec09bf
refactor: rename Int (tag) -> Bits64 (#1343)
ggreif Apr 7, 2020
41dacc7
Basic support for the Float type (#1316)
ggreif Apr 7, 2020
b4ae803
refactor: share prelude definitions (#1349)
ggreif Apr 7, 2020
c219df4
default.nix: Slightly more idiomatic `musl-wasi-sysroot` (#1350)
nomeata Apr 7, 2020
396ff25
Float module, initial draft (#1351)
matthewhammer Apr 7, 2020
652409e
niv musl-wasi: update 4b41c5d5 -> 86550c37 (#1352)
dfinity-bot Apr 8, 2020
485804c
niv-updater: blacklist musl-wasi for now (#1354)
ggreif Apr 8, 2020
56f626e
publish floatToText as a primitive (#1355)
ggreif Apr 8, 2020
fcfce39
Test case: static-call-from-pub (#1346)
nomeata Apr 8, 2020
e40f4e9
Const: Ignore top-level-bound free variables for FuncE (#1348)
nomeata Apr 8, 2020
cf02ea7
Compile: Make use of the const flag (#1336)
nomeata Apr 8, 2020
2299768
test compile_lit for Word8/16 and Nat/Int (#1356)
ggreif Apr 8, 2020
a169a74
Nixpkgs: Try 20.03 (#1266)
nomeata Apr 8, 2020
a6cb9c3
niv common: update 22f5d566 -> 96395685 (#1362)
dfinity-bot Apr 9, 2020
11c50ae
Merge branch 'master' of github.com:dfinity-lab/motoko into joachim/u…
nomeata Apr 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 34 additions & 11 deletions design/Units.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ The syntax of a unit -- and therefore an AS source file -- is a sequence of *imp

Imports are no longer allowed anywhere else.

The `<text>` of the `import` statement is an URL. The precise interpretation is implementation dependant (see below in section Compilation). It at least support local paths relative to the source file. URLs do _not_ include a file ending, such as `.as`, `.dll` or `.wasm`, to allow for different compilation schemes.
nomeata marked this conversation as resolved.
Show resolved Hide resolved

Each import binds the identifiers in its *import pattern*. If the pattern is a plain `<id>` then the contents of the imported unit is reified as a module object bound to that id. If the pattern is a *destructuring* import pattern then the respective public fields of the unit are bound to the respective label identifiers.

As a crucial restriction, a unit that has at least one public field must be *static*, see below.
Expand Down Expand Up @@ -92,34 +94,55 @@ The defined actor can still bind and refer to a self variable for the resulting
Similarly, the actor short-hand can be recursive.
(That is, `actor class C() = this {...this...}` and `actor this {...this...}` are allowed, but `actor class C() = {...C...}` is not. If needs be, this restriction may be lifted later.)

## Compilation schemes

The source language semantics can be implemented in various ways of increasing sophistication.

### Source imports

There are no build artifacts.

Imports are resolved to ActorScript source files by appending `.as` to the impot path, and read before or during type-checking of the importing file.

This compilation scheme is suitable for the interpreter, and for early versions of the compiler.


### Incremental compilation

This compilation scheme expresses units as dynamically linkable Wasm modules (according to the [dynamic linking spec](https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For symmetry with the text above, you may mention that: "incremental compilation via Wasm seems incompatible with the interpreter, but will be useful for latter versions of the compiler."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the question is: How will it work with the intepreter? I.e. is there the assumption that the .as files are always available next to the compiled .wasm thing?


## Compilation
Imports are resolved to Wasm modules by appending `.wasm` to the impot path.
nomeata marked this conversation as resolved.
Show resolved Hide resolved

The compilation scheme uses the natural mechanisms in Wasm to express units as modules.
The exported module is mapped to Wasm exports (functions and globals) in an implementation-defined way that may vary between compiler versions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you envision this in addition to the "natural" scheme? I assume the benefit you have in mind is performance? Do we know that's not a premature optimisation? And would it be possible to support optimised calling conventions as an augmentation to the "natural" format, e.g., by exporting additional entry points?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s not (just) performance, it is also simplification.

The “natural” scheme (and I should call you out for using a term that implicit carries judgmental value, but at least you are putting it in quotes ;-)) has lots of complications for the backend – eta-expansion of closures, re-boxing of modules on the importing side, specifying a stable name mangling of field names.

So I expect to implement this scheme will be implemented before the “natural” scheme, which would already give us a usable model for incremental compilation. And the “natural” scheme can follow later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, surely, supporting two schemes is not a simplification?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but starting with the simpler, more flexible scheme is :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you are suggesting it as a temporary solution? Why put it in the design doc then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I am suggesting this as a viable, useful and realisitc solution for 0.5 and 1.0, leaving the “natural” solution (which I am still not sold on) in the document as a vision for post 1.0 as a compromise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Selling me on this would require a convincing response to, say, #452 (comment). Or a concrete usecase for who would use these “natural” entry points – especially since you admit that asc itself would be allowed to export and use additional faster entry points.)

Copy link
Contributor

@rossberg rossberg Jun 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you're doing there ;). But I'm afraid I'll insist that this doc describes the finalised module representation, and that it's what we should have implemented by 1.0. If you think we can move faster by first doing a temporary hack that's fine, too, but it can't be more than that.

Look, Wasm defines a notion of module where the entry points to a module are represented as exported functions. That is what every tool and framework in the eco system understands. It is what relevant developments like WASI build upon. It is the minimum foundation to enable interoperability. (The only alternative is sharing a single table across all modules, and that introduces tighter coupling and hence is a less modular approach. Edit: it also causes more trouble for orthogonal persistence.)

AS isn't an island. To be practical we'll eventually need to support linking with foreign libraries in user land. And clearly we want no N^2 FFI and tooling problem. Hence, ultimately the question isn't whether we support the native platform mechanism, but only whether we also maintain something home-brewed in addition. Clearly, it wouldn't be a simplification but a complication to maintain two different mechanisms. The only justification for such a complication would be a significant performance improvement, but currently that's hypothetical and hence a premature design optimisation. Should we ever identify this as a bottleneck, and should whole program compilation not be good enough to address it, then we can still add a secondary mechanism to the design.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, then we are at an impasse.

An AS module exports AS values of various types. Some of them have don’t have function types, some dot. That does not make them WebAssembly functions! AS function ≠ WebAssembly functions – the former can be closures, they can be computed, they can be put in heap data structures, some may not even be WebAssembly functions (e.g. if an argument has type None, they might feasibly be absent).

Maybe at some point there is an realistic interop story for WebAssembly. And maybe we want to use it. That’s already two maybes that are likely not true for our 1.0.

But even if these maybe become true, there will still be a significant mismatch between anAS function and a WebAssembly interop function! Bridging this mismatch will likely

  • incur an implementation overhead (already hinted here: eta-expanding non-manifest functions, for example)
  • incur a performance overhead (marshaling arguments from and to our uniform representation)
  • require developer guidance (i.e. how to marshal these arguments, if that is not completely type-driven)
  • still require special handling by non-AS code, such as initializing the AS runtime and somehow coordinating memory management.

So the viable path I see is a separation between

  • AS modules (for consumption by other AS code) without any external usability guarantee, using the “flexible” format, and
  • Interop modules (for consumption by other WebAssembly code), using a “natural” interop format, with some stability,
    and I expect the latter to be it’s own kind of AS unit, because of additional restrictions on what we can export (e.g. only types that have meaning in the interop world), and maybe additional requirements from the user (e.g. annotations on how to present/expect arguments).

This is not a N^2 FFI story. There is only a single FFI story. But it is an FFI story, not a “all AS code can interop” fairy tale story.

There are some languages that can pull of the seamless integration with a low-level interop language. Rust code, for example, is particularly easy to call from and to C. But that is because it is a low-level language! A high-level language (with RTS and GC, including Ocaml, Haskell, but also like AS) cannot provide that, and usually has dedicated, separate support for “creating a native library”.

And even Rust code does not provide a native library by default, but you have to tell the compiler to do so (via crate-type = ["dylib"], for example), and requires annotations like #[no_mangle].

So what you want to achieve here seems to be overly ambitious for what we need to deliver, and also seems to be guided by your vision for a bright WebAssembly world, rather than what we actually need.


A custom section `as-type` in the Wasm module is used by the compiler to include the type of the unit.

A custom section `as-interface` in the Wasm module may be used by the compiler to include any other information needed by the code generator, such as specialized calling conventions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should put everything dedicated to AS into a single "actorscript" section with subsections. Spreading it over multiple sections introduces a bit of extra complexity.

(FWIW, we should do the same with the Dfinity section.)

Do we also envision the possibility of an DIDL section? Or should that be described somewhere else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should put everything dedicated to AS into a single "actorscript" section with subsections. Spreading it over multiple sections introduces a bit of extra complexity.

I think there is merit in separating the information needed for the type checker (and, e.g., a SDK) from the information needed for the code generation. We can even make a stable specification for the former.

(FWIW, we should do the same with the Dfinity section.)

What is the DFINITY section? The one for the old system API? That should be gone with the new System API anyways.

Do we also envision the possibility of an DIDL section? Or should that be described somewhere else?

Clearly somewhere else, as it is language-independent, and needs input from the SDK team. Also, it would be a section on a deployable canister module, not an AS unit, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may still need a custom section to declare which memories/tables/globals are supposed to be persistent. Though come to think of it, we might differentiate that with appropriate import naming conventions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? I thought the point of orthogonal persistence is that, well, the whole state (“store” as per WebAssembly spec) is persisted.

But this is out of scope for this discussion. If there is a need, a PR against the end2end spec would be appropriate.



## Natural and separate compilation

This extension to the former scheme explicitly uses _natural mechanisms_ in Wasm to express units as modules.
That enables the best possible integration and interoperation with the wider Wasm eco system and existing tools.
(However, it does not automatically enable functional interoperability with other languages, since AS types typically have a representation that cannot directly be interpreted externally. For this, additional interop support would be needed, which is beyond the scope of this proposal.)

Consequently, all units are compiled to Wasm modules.
Their public fields become Wasm exports.
Consequently, every public field of a unit becomes a a Wasm exports.
nomeata marked this conversation as resolved.
Show resolved Hide resolved
These are either Wasm functions, for public fields of function type,
or Wasm globals, for all others.
Compiling arbitrary closures into exported Wasm functions may require eta-expanding the closure and storing its environment into an internal global.

A Wasm module compiled from AS contains a Dfinity-relevant custom section as well as an AS-specific custom section describing the AS type of the module or actor.
No `as-interface` custom section may be present; the interface must be determined by the type alone. This allows true separate compliation.
nomeata marked this conversation as resolved.
Show resolved Hide resolved
nomeata marked this conversation as resolved.
Show resolved Hide resolved

It also implies that compiling arbitrary closures into exported Wasm functions may require eta-expanding the closure and storing its environment into an internal global.

Imports expect the import URL to resolve to a Wasm module compiled from AS and link its exports accordingly.
An import that is not destructured via a module pattern is reified into a module object at the import site.

Programs and libraries are compiled exactly the same.
That is, both create dynlib sections.

Actors are different.
Their exported functions are wrapped into methods de/serialising their arguments and results according to the IDL epcification.
Their exported functions are wrapped into methods de/serialising their arguments and results according to the IDL sepcification.
nomeata marked this conversation as resolved.
Show resolved Hide resolved
Furthermore, they are complemented with system exports for initialising the actor (given the actor class'es arguments) and for in/externalising the actor's state for upgrades (details TBD).

(For release 0.5, we do not yet intend to support separate compilation, and imports will resolve to source files compiled in a whole program manner instead.)


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the negation is true: 0.5 will support these things? Sorry, I'm forgetting the consensus opinion about the timeline for these features, though I know we've discussed that before.

I don't see this question answered in the AS planning google doc, but maybe I missed it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think we need to enshrine it in the design docs. But yeah, 0.5 would do “Source imports” I think

### Compiler

We need two compilation modes, one for programs/libraries, the other for actors. We could differentiate based on file extensions, but that would get in the way of dual-using an actor source file as a library.
Expand Down