Skip to content
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

Event handlers depend on a deprecated feature #1101

Open
dhil opened this issue Feb 10, 2022 · 0 comments
Open

Event handlers depend on a deprecated feature #1101

dhil opened this issue Feb 10, 2022 · 0 comments

Comments

@dhil
Copy link
Member

dhil commented Feb 10, 2022

The implementation of event handlers in Links depends on the deprecated property window.event (c.f. https://developer.mozilla.org/en-US/docs/Web/API/Window/event). Links exposes this property via a built-in global variable called event.

Ideally, we do not depend on deprecated stuff. However, we need to be careful if we remove event (which by the way is exposed as an uninvocable function*) as we need some other means for retrieving the event context.

I see two approaches:

  1. Require all user-defined event handlers to accept the current event as a parameter. This would enforce a strong restriction on the type of things one can put inside l:.
  2. Have the Links Javascript runtime record and store the current event (similarly to how it is done now). Change event : Event to getCurrentEvent : () ~> Option(Event), which returns None if it is invoked outside of an event handling context or Some(ev) if inside an event handling context, where ev would then be bound to the current event. If done naively (as it is currently the case) then different event handlers can read different events depending on when they invoked getCurrentEvent, we can probably rectify this by making the JavaScript process scheduler take care of the event bookkeeping.

* In the REPL

links> event;
fun : Event
links> event();
<stdin>:1: Type error: The function
    `event'
has type
    `Event'
while the arguments passed to it have types

and the currently allowed effects are
    `wild:()'
In expression: event().
@dhil dhil changed the title Event handlers depend on deprecated feature Event handlers depend on a deprecated feature Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant