lingua-franca
lingua-franca copied to clipboard
How to handle deadlines on bodyless reactions?
While implementing bodyless reactions for C++ (https://github.com/lf-lang/lingua-franca/pull/1933), I realized that it is currently not possible to have a bodyless reaction with a bodyless deadline handler.
In C++, we currently generate a function <name>_body
that represents the reaction body, where <name>
is the name of the reaction or a generated name if the reaction is unnamed. If there is a deadline, we also generate a function <name>_deadline_handler
. Thus, it is easy to disambiguate the two and provide external implementations to both. Should we just make the body of the deadline handler optional too? How should we handle this in C?
I have not formed a strong opinion about this since I have not worked on LF programs that are large or that have more than a few deadlines. I would be fine with either (1) requiring deadline bodies to be inlined, (2) giving them a formulaic name such as <name>_deadline_handler
based on the reaction name, or (3) letting them be given their own names. Any of these three could probably be implemented in the C target, and I do not think there is any reason to allow inconsistency with the C++ target in this regard. If I understand, you are advocating for (2), which sounds good to me.
The current implementation in the C target does not append _body
to the end of the reaction name, but that could be changed if we like. However, I do not see much reason to change it except for the purpose of being similar to the C++ target.
If I understand, you are advocating for (2), which sounds good to me.
Yes, but the only reason is that it is already implemented like this in the C++ target.
But its good to know that there are no roadblocks for either of the options in C.