Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Attributes and syntax extensions for the built-in timers #420

Open
pdeligia opened this issue Mar 22, 2019 · 0 comments
Open

Attributes and syntax extensions for the built-in timers #420

pdeligia opened this issue Mar 22, 2019 · 0 comments
Labels
compiler Feature related to the compiler language-design Feature related to the language design usability Issue or update regarding usability

Comments

@pdeligia
Copy link
Contributor

Low-priority proposal. It would be nice to have attributes and syntax extensions that simplify using the new built-in timers.

For example, instead of the user having to explicitly handle a TimerElapsedEvent, they could use an attribute such as:

[OnTimeoutDoAction(nameof(HandleTimeoutForPing))]
class SomeState : MachineState { }

instead of:

[OnEventDoAction(typeof(TimerElapsedEvent), nameof(HandleTimeoutForPing))]
class SomeState : MachineState { }

Also, the HandleTimeoutForPing would now receive the TimerInfo as argument (instead of having to access the TimerElapsedEvent which would be internal.

void HandleTimeout(TimerInfo info) {
  ...
}

instead of:

void HandleTimeout() {
  var info = (this.ReceivedEvent as TimerElapsedEvent).Info;
  ...
}

This can be supported in the P# syntax on something like:

on timeout do HandleTimeout;
@pdeligia pdeligia added language-design Feature related to the language design usability Issue or update regarding usability compiler Feature related to the compiler labels Mar 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler Feature related to the compiler language-design Feature related to the language design usability Issue or update regarding usability
Projects
None yet
Development

No branches or pull requests

1 participant