-
Notifications
You must be signed in to change notification settings - Fork 108
Distributed Computing (proposal)
Raivat Shah edited this page Mar 5, 2021
·
4 revisions
Idea: Introduce Promises in Source 2 to facilitate distributed computing.
- Student A executes:
function my_shared_function(x) {
display(x);
}
share(my_shared_function); // returns access-token
-
REPL displays the access token
"2e7d5196-bc90-4482-9b9f-749b6c23b089"
-
Student A sends the access token to Student B (e.g. through Telegram)
-
Student B executes:
const promise = connect("2e7d5196-bc90-4482-9b9f-749b6c23b089");
then(promise, shared_function_from_a =>
shared_function_from_a("hi there");
}
- Student A sees "hi there" in their REPL
- Student A executes (whats_your_name could be from a library):
function whats_your_name() {
return prompt("what's your name?");
}
share(whats_your_name);
-
A's REPL shows string
"2e7d5196-bc90-4482-9b9f-749b6c23b089"
-
Student A sends string to Student B
-
Student B executes
const promise = connect("2e7d5196-bc90-4482-9b9f-749b6c23b089");
then(promise, shared_function_from_a => {
const my_promise = shared_function_from_a();
then(my_promise, name => display(name));
}
-
Student A gets a prompt:
"what's your name?"
, and enters"Raivat"
-
Student B sees
"Raivat"
in the REPL