Conversation
this starts implementing the plan in #867 (comment) No values are in scope by default. In bare uses of Motoko: Use `import Prim "mo:prim"` to get `Prim.debugPrint` etc. In real uses, the `stdlib` should provide everything you need. Quite some churn in the test suite. Went through `run` and `fail` so far.
3a55d9f to
ee0d31d
Compare
|
I hit a snag: Nested modules. Although they are not supported in Previously this compiled due to a horrible hack about prelude definitions in the backend. But the hack does not apply to What to do? Maybe simply stopping to use local actors in the test suite (or only in the interpreter)? I guess there are actually just a few of these. Disabling on (Working on updating |
f606155 to
8bc9992
Compare
and move the test projects into its own directory, to avoid spurious recompilation of the `lsp-int` binary.
but somehow this does not compile. @ggreif, can you help?
|
@ggreif I have some problem adjusting |
b7a4c47 to
c3b6a88
Compare
I am working on this. Just for the record, one can run a subset of the tests by (e.g.) env PATH=$PATH:src $(nix-build -A qc-motoko)/bin/qc-motoko -p failureswhich will leave behind specific It appears that "import Prim ..." is prefixed on every line, but it is only allowed at the top of the program. This is for the |
|
@nomeata please merge |
|
Ok, CI is happy. |
kritzcreek
left a comment
There was a problem hiding this comment.
This looks great, do you think we want to hold off on this until after Davos? This is definitely going to break code in linkedup (having to add the Prim import) and I don't know when the next DFX release is happening so we might end up dropping this change on them very shortly before the demo.
| parse "mo:foo/bar" = Ok (Package ("foo", "bar")) | ||
| parse "mo:foo" = Ok (Package ("foo", "")) | ||
|
|
||
| parse "mo:prim" = Ok (Prim) |
There was a problem hiding this comment.
Not saying it needs to happen in this PR, but these comments look like they should be unit tests?
src/prelude/prelude.ml
Outdated
| This module should contain everything that cannot be implemented in plain | ||
| Motoko. It is available via `import Prim "mo:prim"`. Normal user code would | ||
| usually not import that module directly, but through the stdlib, which takes | ||
| care of providing a prober module structure, e.g. exposing Array_tabulate |
There was a problem hiding this comment.
| care of providing a prober module structure, e.g. exposing Array_tabulate | |
| care of providing a proper module structure, e.g. exposing Array_tabulate |
ggreif
left a comment
There was a problem hiding this comment.
This is big. I have just skimmed the surface. But I agree, this needs to be done before lots of big (d)apps grow in the wild. Is LinkedUp informed about upcoming changes? Also @lsgunnlsgunn should be in the loop so she is prepared.
Co-Authored-By: Gabor Greif <gabor@dfinity.org>
Co-Authored-By: Gabor Greif <gabor@dfinity.org>
Actually it isn’t so big:
Would you prefer one PR that adds the infrastructure (unchanged prelude, empty
Judging from updating the produce exchange, there isn’t much to do. Outside users should usually not import The biggest one is Mostly We can maybe port LinkedUp ourself and provide a PR with the changes needed for that. |
Actually, that sounds like a good idea. Will do that. |
this make `import "mo:prim"` import the module in the `prim_module` string in `prelude.ml`. This is currently empty; the code is added in PR #1088.
|
See #1093. Now with a warning upon |
* Infrastructure for the hard-coded prim module this make `import "mo:prim"` import the module in the `prim_module` string in `prelude.ml`. This is currently empty; the code is added in PR #1088. * Print an error upon `--package prim ...` * Update src/prelude/prelude.ml Co-Authored-By: Gabor Greif <gabor@dfinity.org> Co-authored-by: Gabor Greif <ggreif@gmail.com>
There was a problem hiding this comment.
I think this is good to go, with following caveats:
- heads-up to @enzoh and other teams
- needs mention in Motoko user manual
- snippets for
rangeandhashIntso that users can include it themselves.
Please choose the merge time with consideration of the Bronze situation.
The merge conflicts in the test suite will not be fun, but maybe that’s reasonable. OTOH, if we prepare the stdlib so that they don’t need to import prim (just |
Co-Authored-By: Gabor Greif <gabor@dfinity.org>
|
See dfinity/linkedup#3 for how small the fallout on Linkedup is |
|
If they're fine with it that's great. I just didn't want to put one more thing on their plate. |
* Stdlib: Export some conversion functions also in Nat and Int this anticipates #1088: With this change, the LinkedUp code can be changed to use only the stdlib, but _no_ definitions from the prelude. This means that #1088 would not break LinkedUp. * Likewise, export Array.{init/tabulate} * Expose Debug.print
|
Yes, that’s absolutely right in asking for caution here (and I am glad you made me look at LinkedUp). |
this starts implementing the plan in
#867 (comment)
No values are in scope by default.
In bare uses of Motoko: Use
import Prim "mo:prim"to getPrim.debugPrintetc.In real uses, the
stdlibshould provide everything you need.Quite some churn in the test suite. Went through
runandfailsofar.