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

Introduce forever time literal #2421

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Introduce forever time literal #2421

wants to merge 8 commits into from

Conversation

Depetrol
Copy link
Collaborator

@Depetrol Depetrol commented Oct 5, 2024

This PR introduces a new forever time literal that can be used as STA and STAA in decentralized execution. This PR is related to #2368 and closes #2374.

@Depetrol Depetrol added enhancement Enhancement of existing feature feature New feature labels Oct 5, 2024
@lhstrh
Copy link
Member

lhstrh commented Oct 7, 2024

Keywords in LF are all lowercase -- let's stick with that?

@Depetrol
Copy link
Collaborator Author

Depetrol commented Oct 7, 2024

Makes sense! I'll modify the PR.

@Depetrol Depetrol changed the title Introduce FOREVER time literal Introduce forever time literal Oct 7, 2024
@Depetrol Depetrol requested a review from lhstrh October 7, 2024 05:54
@edwardalee
Copy link
Collaborator

It's unclear to me how this is used. I don't see any changes in the code generator to detect "forever" and then use the C macro FOREVER. How does this get used?

@Depetrol
Copy link
Collaborator Author

Depetrol commented Oct 7, 2024

This implementation does not use the C macro FOREVER. Instead, it introduces a new Lingua Franca time literal named forever in the Xtext syntax, and when the compiler sees this time literal it interprets this time literal as TimeValue.MAX_VALUE. This is similar to how the compiler currently handles the 0 time literal. The benefit of this implementation is that it is target language agnostic.

@edwardalee
Copy link
Collaborator

This implementation does not use the C macro FOREVER. Instead, it introduces a new Lingua Franca time literal named forever in the Xtext syntax, and when the compiler sees this time literal it interprets this time literal as TimeValue.MAX_VALUE. This is similar to how the compiler currently handles the 0 time literal. The benefit of this implementation is that it is target language agnostic.

Ah yes, that makes sense.

Copy link
Collaborator

@edwardalee edwardalee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no practical use case fornever? If there is, then shouldn't it also be allowed as a time value?

@Depetrol
Copy link
Collaborator Author

Depetrol commented Oct 8, 2024

I haven't yet encountered a use case where never is used. However, if there is a use case for it, I would be glad to add it to the syntax as well!

@Depetrol
Copy link
Collaborator Author

Depetrol commented Oct 8, 2024

I was looking into the tests and found a test LastTimeReplace.lf that uses the never time literal. It is noted that

reaction(startup) {=
    // Unfortunately, a time state variable cannot be initialized with NEVER.
    // So we do that here.
    self->last = NEVER;
  =}

I think introducing the never time literal makes sense in this use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing feature feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse target variable STP (STAA)
3 participants