-
Notifications
You must be signed in to change notification settings - Fork 106
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
Modules: Proposal: import syntax for Source §1-§4 #399
Comments
Yes, I think that's a good suggestion. Ideally we would also have some sort of autoimport feature built into Ace (since it's really troublesome to have to keep adding library functions to the import statment in the midst of solving a mission). Otherwise I can foresee this "header file" that includes all library functions being prepended to Source programs which would defeat the purpose of this. Haven't gave it too much thought on the implementation side. |
For solving missions, our template would already provide a sufficient import directive, and the students would be advised not to change it. |
Shouldn't a program be allowed to contain more than one statement? |
You are right. It should be statement... (corrected above) |
I would recommend allowing aliased imports for ease of implementation. I think it is impossible (without hacks) to differentiate between |
I agree. I've changed the proposal above accordingly. |
I'm proposing to allow the following syntax in Source:
This means that we will explicitly import modules (libraries) from now on, in order to use them:
This will:
For Source 2021, the path will be resolved to:
https://github.com/source-academy/modules/tree/master/
This means that
from 'lib/runes'
refers tohttps://github.com/source-academy/modules/tree/master/lib/runes.js
(the default file extension will be .js)The Source Academy frontend will fetch the module from the backend, which of course will cache it. Our modules can still be written in JavaScript and loaded in the frontend in whatever way works (e.g. eval).
In the future, we can allow for a more flexible scheme where users can import Source programs using the same syntax.
The text was updated successfully, but these errors were encountered: