Open TheHarvard opened 3 years ago
If @RobotSigmund or @AGus-RN Have comments on this, then feel free to add them here.
if we resolve this i think we can close #37
RNL group meeting 2020/01/05 with: @TheHarvard @RobotSigmund
"Clear" and "Set" are allready instructions in RAPID. Both commands are non essential for RAPID, and have more readable altarnatives. We don't consider it an issue overwriting theese.
Actions:
Start development of a linked list strcture using datapointers.
Data Storage in programs
This issue aims to create a discussion around how we should store data in programs.
The standard (and only) way to store data in RAPID programs has been statically declared Data and Arrays. While these are highly efficient, and should be used when approprierte going forward, we are also seeing that some new, more sophisticated options are becoming possible as part of the RNL library.
The problem of Static declaration
The main limitation of the standard data declaration in the RAPID programming language is that the data is statically declared, meaning:
This often leads to dirty solutions with temp-data or meta counters to signify what parts of the arrays are in use.
New data storage types
As RNL implements concepts like the datapointer, we see that the following alternative storage methods are becoming viable:
The linked list
By linking multible datapointers in a chain you can create a list that can:
Due to the inherent design of the list, the code needs to crawl over all elements until it finds the one it wants to perform some operation on. This mean that speed drops proportionally with list length.
A list would also behave exactly like an object, allowing you to create a list of lists for a multidimensional matrix.
A large number of sub types of the linked list could also exist. these sub types could enforce useful restrictions (like enforcing a FIFO queue) or alter the behaviour (Emulating unordered lists). Examples can be:
The dictionary
A dictionary is a list of key value pairs that has the same benefits as linked lists.
A dictionary can be made of a linked list that refers to each key value pair, or it can structured as a hash table.
I propose we use linked lists as default for dictionaries, and have a different structure called "Hashtable" for hashtables.
The Hashtable
The Hashtable is a structure for storing data where a specific element can be reached by supplying a key. The key is decoded into a number (Hashed) and this number indicates where in the hashtable the element exists. In theory, a hashtable should be more efficient than a linked list for large sets of data, but comes with a couple more limitations. Whether we can implement it in rapid in a way that emphasizes this boost to efficiency is uncertain; we might have to use arrays with static sizes to avoid having to crawl over all elements in a linked list.
Terminology
When implementing these new structures, we should settle on a unified terminology to use across all programming.
I propose the following:
In the table below i have set up two sets of methods and operation that you can imaging being generally universal for data storage. I have taken inspiration from C++ and Pythons approach and naming convention. I have set up a main colum with what i belive would be the better option, but i have also set up an alternative colum containing a slightly different approach.
Comments to which one is more intuitive and readable is welcome.
Actions
We should determine if this is an appropriate way to build data lists, and that this naming convention is approprierte.
Once done, we can start developing these structures and enforcing the convention.