-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Preambles of base classes are not included #1372
Comments
The following compiles and works fine for me. If we allow non-private methods, then we may as well use them. Christian commented a few years ago that
I wouldn't want to belabor a point that has already been under discussion for years (#33), but it seems non-obvious that non-private methods (or preamble inheritance, given that we can declare state variables in preambles) is a good idea. Such things do break encapsulation. As in an OO language, composition can solve this (without using special constructs like methods or preambles):
|
The semantics of preambles in combination with imports (and also inheritance) is still a mystery to me. That's also why #33 is still open. However, I think the issue here is that we never tried to modularize the generated code. I am not sure if it changed in the meantime (AFAIK it did not), but back then the visibility of preamble code completely depended on the order in which the code generator would place reactors in the generated C file. This means that some reactors see preambles that they shouldn't see and some don't see preambles that we might expect them to see. |
For the robot interface, it might actually make sense to place the functions in separate header and source files. This would give a cleaner interface to be used by the robot control reactors. |
For my particular problem with the robot, I have done what @cmnrd suggests and put the functions in a separate .h/.c file. However, the bug still stands, because the #include has to be put in a preamble, and the preamble will not be inherited. |
I'm facing the same problem in python targets in LF 0.8.1. target Python;
reactor RosNode {
preamble {=
def initiation() {
printf("Hello World\n")
}
=}
}
reactor PIController extends RosNode {
reaction(startup) {=
self.initiation()
=}
}
reactor PIDController extends RosNode {
reaction(startup) {=
self.initiation()
=}
}
main reactor {
e = new PIController();
} An error will occur when executed.
In my use case (the code above is a minimal sample of this use case), I would like to know if there are any workarounds or revisions planned for this issue. |
This is fixed in PR #2381 . |
The C code generator (at least) does not include the preambles of a base class, which causes code to fail to compile. Minimal test case:
This causes a compile error:
Unfortunately, this is making it very hard to provide a clean robot interface for EECS 149 labs.
The text was updated successfully, but these errors were encountered: