tonyg / syndicate

syn·di·cate: a language for interactive programs
http://syndicate-lang.org/
GNU Lesser General Public License v3.0
152 stars 11 forks source link

`react/suspend` should be implemented with `stop-facet` #28

Open tonyg opened 7 years ago

tonyg commented 7 years ago

At present, there is a lot of special-purpose machinery around react/suspend to schedule the suspended continuation when it is invoked, ensure termination of the created facet, prevent multiple invocations of the continuation (!!?!?!) etc. I think it might be a lot simpler if instead we implemented it so that invoking the wrapped continuation just calls stop-facet on the created facet, with a call to the raw continuation inside the stop-facet. That should Do The Right Thing, given that stop-facet already transplants execution to the parent of the facet-being-terminated.

Something like this:

E[(react/suspend (k) P)] ==>
(let ((the-facet (current-facet-id)))
  (react (let ((k (lambda (v) (stop-facet the-facet E[v])))) P)))

The until macro would need to be adjusted to match, to say (on E (continue (void))) instead of the current (stop-when E (continue (void))).