Comments (8)
The internal structure of both Tuple
and Object
types are nested, e.g., Tuple<char, int, float>
is shorthand for Tuple<char, Tuple<int, Tuple<float, Tuple<>>>>
. If these types were merged, data in such a structure would be presented to the caller as an overly complicated nested structure, e.g., ('a', (10, (1.2)))
instead of the expected ('a', 10, 1.2)
.
To circumvent this, we need two types of these objects, one that serialises to a flat list and one that has an explicit internal structure. To stick with the previous example, Object<char, int, float>
is shorthand for Object<Tuple<char, Tuple<int, Tuple <float, Tuple <>>>>
and data in such a structure is presented to the caller as a simple tuple, e.g., ('a', 10, 1.2)
.
So in a sense, the Object
type places the parentheses around the values. This however means a bare Tuple
no longer has a representation for the caller.
I will try to explain this in the documentation as well.
from arduino-simple-rpc.
I tried to explain it in this note.
from arduino-simple-rpc.
Yeah after playing with it more I see the concept and understand the idea. Indeed merging them makes little sense. Perhaps my confusion is purely based on semantics about what the flat type is called and what the nested type is called. In a sense I was thinking of Object
as the flat one, perhaps due thinking about them like structs
in C, and Tuple
as the nested one.
Regardless this was my mistake and I agree on all points you have made. I obviously missed the note! Sorry for the noise. Feel free to close the Bug Report. As always thank you for the excellent library
P.S
As an aside, I personally prefer to use the STL, even on Arduino, so I have patched your C++ library to at least support std::string
, but I could likely include support for std::vector
and std::array
(or others). Is that something you are interested in? If so I can open a feature request on the other repo and eventually put in a PR for them. I don't mind maintaining internal patches for the stuff we are working on but I only bring it up because support for Arduino String is there. I understand what we are doing is somewhat niche (power management for an RF system) so I don't want to overstep.
from arduino-simple-rpc.
You did not miss the note, I wrote it after you opened this issue.
I would have preferred using the STL as well, but to my knowledge it is not distributed by default with the Arduino cores. If this is the case, it may be a bit more difficult for an end user to use this library. Of course I could be wrong here.
from arduino-simple-rpc.
I just thought I could give it a go, but the standard installation does not seem to work, at least not in my setup. As soon as I include ArduinoSTL.h
, I get the following errors.
.../libraries/ArduinoSTL/src/del_opvnt.cpp:25:58: error: 'nothrow_t' in namespace 'std' does not name a type
_UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) throw(){
^~~~~~~~~
.../libraries/ArduinoSTL/src/del_ops.cpp:25:50: error: 'std::size_t' has not been declared
_UCXXEXPORT void operator delete(void* ptr, std::size_t) throw(){
^~~~~~
.../libraries/ArduinoSTL/src/del_opnt.cpp:25:56: error: 'nothrow_t' in namespace 'std' does not name a type
_UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) throw() {
^~~~~~~~~
.../libraries/ArduinoSTL/src/del_opvs.cpp:25:53: error: 'std::size_t' has not been declared
_UCXXEXPORT void operator delete[](void * ptr, std::size_t) throw(){
from arduino-simple-rpc.
Mini rant to start: I honestly hate how Arduino pushes this weird C within C++ style of programming. I understand they are trying to be beginner friendly but I feel it creates a bunch of weird corner cases when you are trying to do something a little more involved. Mini rant over.
So honestly I have not used ArduinoSTL.h
but those errors seemed strange. A quick Google search points to these threads: 1 and 2 which tl;dr suggest changing #include <ArduinoSTL.h>
to #include "ArduinoSTL.h"
or changing Arduino IDE version
All that said the way I use the STL is to include -lstdc++_nano
in the build flags. For the Teensy line of boards I modify boards.txt > teensyXX.build.flags.libs
to include the additional library. For Arduino it is somewhat more involved, requiring either arduino-cli
or modifying other .txt
. files (some info here). The nice thing about lstdc++_nano
is it does not throw, is relatively light weight and imo fulfills the role of ArduinoSTL.h
.
Of course modifying Arduino files is daunting for many users so I understand that any STL inclusion would cater to a niche of a niche.
(edit: made links visible)
from arduino-simple-rpc.
Changing the <>
to ""
did not help. I am also not sure whether this library is still maintained.
I mainly use arduino-cli
for my projects and adding a build flag seems to be rather straightforward. Do you perhaps have an example project where std::string
is used together with build options, include and library paths?
I would not mind adding some optional extra complexity. We could think about an additional include for STL support in conjunction with some build instructions.
from arduino-simple-rpc.
I opened discussion #24 for this topic.
from arduino-simple-rpc.
Related Issues (13)
- Unclosed file warning triggered on import HOT 1
- cannot import class methods HOT 3
- Speed up ethernet / wifi comms HOT 3
- trying to use spy:// (pyserial feature) with Interface mistakes it for a host address HOT 3
- Initialize interface from disk HOT 13
- Ethernet support HOT 3
- Type hinting using any vs typing.Any HOT 3
- Adding timeouts to the library HOT 7
- Type hinting correction on *args and **kwargs in function definitions HOT 2
- client library in C HOT 1
- Module hangs on _get_methods() HOT 2
- Open / close the port often for ethernet comms HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-simple-rpc.