[bundle] Request-Response centric construct for improvement of Diagrams #1781
Replies: 5 comments 23 replies
-
I don't understand why this isn't more easily and clearly addressed using inheritance plus a change in the diagram layout that would allow input ports on the right. |
Beta Was this translation helpful? Give feedback.
-
Wouldn't a base class with parameterized multiports accomplish this? |
Beta Was this translation helpful? Give feedback.
-
The hashtable access example looks a bit awkward to me. Wouldn't it be better to just have one connection and include in the struct that you send to the hashtable an enum specifying the command (add, has_element, get_element, remove, update_element, or update_key)? The response could similarly be a struct where fields suitable to the response are set. In any case, I get your point that the bundle syntax could, in some circumstances, make a specification more concise. But I feel that any addition to syntax comes with considerable costs: It complicates documentation and tutorials, creating higher barriers to entry; it complicates subsequent innovation (e.g., the bundles will need to be supported in federated execution); and it opens up potential confusion by giving multiple ways to achieve the same thing. I am not convinced that this particular syntax change is worth these costs. To be clear, we can leave this open, but Berkeley does not have the resources right now to address this. We have too many other priorities in the works. I'm OK with it if someone else picks this up. |
Beta Was this translation helpful? Give feedback.
-
I talked to @mkhubaibumer, @OmerMajNition, and Andy this morning and it sounds like Magnition may be able to implement this, as long as they are able to ask for feedback so that they do not go down the wrong track and so that they have some assurance that their changes can be merged when they are complete. I can imagine a few possible scenarios for how this would work. None of these should cause backwards-incompatible changes. I think I have a personal preference for scenario 1. If scenario 1 is done correctly, I think that it will not affect or increase the complexity of other parts of the code base and will not require very much maintenance overhead after being implemented. Given that this is not a feature that the team at Berkeley is able to invest a substantial amount of resources into, I think it is good to choose an option that is reasonably self-contained and that eliminates bundles from the version of the AST that most of the code base (excluding the validator) operates on. I also like scenario 1 because I am not pleased about the prospect of making more awkward changes in order to accommodate a particular usage of C syntax. I think that such changes will not translate well to other languages that we might want to use with the C runtime. Scenario 1: Transform just to regular ports; use port aliases or magic characters such as underscoresImplementation
Estimated time: 2-6 weeks Disadvantages
Advantages
Scenario 2: Transform just to regular ports; do not use port aliasesSimilar to scenario 1. Instead of requiring the implementation of port aliases, this would require invasive changes in the C generator. These invasive changes would touch the Disadvantages
Advantages
Scenario 3: Transform just to regular ports; do an AST transformation on reaction bodies that transforms dot access notation into magic characters such as underscoresImplementationSame as for scenario 1 with magic characters such as underscores, but with an additional step in the AST transformation that transforms the C reaction bodies as needed. This additional step would take maybe 20 minutes to implement incorrectly. An incorrect implementation that just does a simple regex replacement would be sufficient to try the feature on test programs. In the long run it would likely be necessary to fully parse the C code, which is feasible. There exist publicly available C parsers. Estimated time: Same amount of time as scenario 1 to implement incorrectly; unknown (maybe 2-6 additional weeks) to implement correctly Disadvantages
Advantages
Scenario 4: Use reactors in addition to creating regular ports for bundles Implementation
Estimated time: 4-8 weeks, but possibly more depending on how we address the problem that sometimes two dot accesses appear in the the same expression. Probably that problem would have to be resolved using some of the same methods as in Scenarios 1-3. Disadvantages:
Advantages:
|
Beta Was this translation helpful? Give feedback.
-
Independent of how this could be implemented, I do like the syntax proposal! I have the feeling that
|
Beta Was this translation helpful? Give feedback.
-
Bundle Proposal
Description
This proposal depicts the core idea for a bundle in Lingua-Franca
This proposal makes three additions to LF Grammar
bundle
to create a bundle entity.Flipped OR Mirrored
which is a code generator hint to make input as output and vice-versaport
keyword to declare a bundleport comm:{Bundle-Name}<...>
This proposal also advises changes to the Language Server as follows:
c.com <-> s.com
c.com.request -> s.com.request
s.com.response -> c.com.response
Why Not Inheritance?
A component can have multiple request/response pairs
In case of Inheritance that doesn't work in a reuse-able fashion.
In the case of Inheritance the Child Reactor will only have one instance of Parent's definition
Even a simple generic bundle with single input single output can be declared
n-times
in a reactor with different names for
n-components
Each of the
port bundle
here in this example is based on perfect request/response patternFor cases like this, which in fact is the most common case Inheritance cannot work simply because this is
out of the scope for Inheritance. In this example I'm using combinations of same
KeyType
andElementType
but in mostof our components we even use types which are internal.
Proposed Syntax
Before bundle
After bundle
Multiport Bundles
The multi-port implementation for bundle can follow one of the following approaches:
Visual Changes
Before
After
Beta Was this translation helpful? Give feedback.
All reactions