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

Support definition of methods similar to state variables #382

Merged
merged 9 commits into from
Jul 13, 2021
Merged

Conversation

cmnrd
Copy link
Collaborator

@cmnrd cmnrd commented Jun 29, 2021

This PR adds support for the definition of methods in LF code. Methods are defined similarly to state variables. They can be invoked from reactions and allow encapsulating certain functionality and also enable code reuse between reactions. Currently, we only have preambles for defining functions, but this is not always sufficient as methods might need to access parameters and state variables or call other methods. In particular, we noticed that we need methods for porting complex ROS nodes to LF in a practical way. This PR also adds a test case, which also serves as a usage example.

This MR depends on #375 and should only be merged once #375 is merged.

@cmnrd cmnrd added compiler cpp Related to C++ target language Related to the syntax and semantics of LF labels Jun 29, 2021
@cmnrd cmnrd marked this pull request as draft June 29, 2021 12:41
@cmnrd cmnrd marked this pull request as ready for review July 2, 2021 14:36
Base automatically changed from cpp-scoping to master July 6, 2021 20:03
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.

Looks good to me! This needs documentation on the wiki.

@cmnrd
Copy link
Collaborator Author

cmnrd commented Jul 13, 2021

@cmnrd cmnrd merged commit 198730f into master Jul 13, 2021
@edwardalee
Copy link
Collaborator

Shouldn't this be in the language specification? (Even if currently only supported by Cpp).

@cmnrd
Copy link
Collaborator Author

cmnrd commented Jul 13, 2021

Oh, right. I completely forgot about the language specification. I also added a description of methods there.

@cmnrd cmnrd mentioned this pull request Jul 16, 2021
24 tasks
@cmnrd cmnrd deleted the methods branch August 20, 2021 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler cpp Related to C++ target language Related to the syntax and semantics of LF
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants