-
Notifications
You must be signed in to change notification settings - Fork 4
Shared/Sink/Source: Provide getters/setter in addition to operator overloading. #67
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
Conversation
@aentinger Sorry, I think I didn't provide enough context. I do think explaining that a shared variable works as a queue will help many users from the target audience to understand the concept. Therefore I'd add |
Thank you @sebromero for providing this feedback. The main problem I see is that the target group is not clearly defined (and as I told you attempts to clarify it have been not successful). The way the APIs are designed right now (operator overloading) are tailored towards a beginner, who is bot bothered by the fact that a I'd like to invite @facchinm to share his thoughts on this subject, since he's been the originator of the operator overloading approach. |
I understand the idea. However I'd argue that from an educational point of view using an assignment operator for something that's not really an assignment is imo confusing for anyone who has the slightest idea about data structures. Ideally the users can leverage any prior programming knowledge. That said, for complete beginners the assignment operator is a legit option but I have some doubts that they can dive straight into multitasking from the beginning. |
The main idea was to easily "retrofit" existing projects by moving the variable definition to SharedVariables.h and leaving everything else as-is. I understand that, as things have been evolving, this doesn't make much sense, give that it must be explained thoughtfully. Maybe we should comment it out and just leave for future reference 🙂 ? |
For this there's already a
Such a problem (multiple consumers reading from a single producer) is indeed a problem that often traps beginners into the multi-threaded world. The Moving on to questions of operator overloading ... I'm not feeling particularly strongly about this but one could argue that providing the operator overloading gives the code the appearance of a plain-old-data-type variable, i.e. if I'd to be assign a plain integer or a int my_var;
my_var = 12;
Serial.println(my_var);
/* vs */
SHARED(my_var, int);
my_var = 12;
Serial.println(my_var); This library will always be a simplification. If you want to leverage the full plate of what a RTOS has to offer you can always directly access the mbed-os API. For reference, consider how EdgeImpuls uses Arduino hardware. They basically start their own thread within Moving I'd suggest to keep both operator overloading and getters/setters for now. But I would replace them with better names that what they have right now. Consequently I'm proposing |
… a simple variable but a queue.
Alternate names that come to my mind are:
although they sound rather generic. What's your take @sebromero @facchinm ? |
Decision per SIG Arduino Language meeting (and absent any further objections in this PR) is too add the getters/setters AND remove the operator overloading in a separate PR (so as to make it easily revertible). |
No more assignment operator, type operator. This leads to less confusion as discussed in #67.
No more assignment operator, type operator. This leads to less confusion as discussed in #67.
This fixes #66 .