-
Notifications
You must be signed in to change notification settings - Fork 108
Closed
Labels
ProposalProposing a feature, please discussProposing a feature, please discussimportantFixing this is important, but not mission-criticalFixing this is important, but not mission-critical
Description
I'm proposing to allow the following syntax in Source:
program ::= importdirective... statement...
importdirective ::= import { importnames } from string;
importnames ::= importname (, importname)...
importname ::= name | name as name
This means that we will explicitly import modules (libraries) from now on, in order to use them:
import { heart as lung, show as view, stack, sail } from 'lib/runes';
view(stack(lung, sail));
This will:
- demystify module loading for students: Source would be in line with other programming languages where imported functionality is explicitly named in programs
- simplify the Source Academy user interface: no more need for a "Library" menu
- simplify js-slang tools: imported names are all explicitly mentioned in the program
For Source 2021, the path will be resolved to:
https://github.com/source-academy/modules/tree/master/
This means that from 'lib/runes'
refers to
https://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.
openorclose, ning-y and seanlowjk
Metadata
Metadata
Assignees
Labels
ProposalProposing a feature, please discussProposing a feature, please discussimportantFixing this is important, but not mission-criticalFixing this is important, but not mission-critical