Closed vdm-dev closed 10 months ago
In the interest of consistency, these three similar functions would ideally work the same: either all three would take a pointer or all three would return a value. It is more intuitive to me to return the number of filled items, like
RoboDK_Selection
does. However, I recognize that there are backwards-compatibility considerations that may make this challenging. It would be suboptimal to have to implement the following...
RoboDK_Selection
always returns the total count of selected items, not the number of filled items.
I'm still not sure how it would be better.
My refusal to use the int32_t *itemlist_sizeout
pointer is due to my desire to minimize the number of function arguments.
But at the same time, I would not want to create copies of existing functions so as not to generate redundancy.
RoboDK_Selection always returns the total count of selected items, not the number of filled items. I'm still not sure how it would be better.
This was my understanding as well. By "number of filled items", I meant:
The number of items that were populated ("filled") into the array located at the
struct Item_t *itemlist
pointer.
This number would be equal to the total count of selected items.
Returning the number of selected items is, indeed, stylistically preferable to passing the pointer. The reason I suggested alternatives is to maintain consistency with the structure of existing similar functions like RoboDK_getItemList
and RoboDK_getItemListFilter
. Making the tradeoff of consistency vs. better structure is certainly a decision that you can and should be responsible for making. The reason I commented on this PR at all is to make sure you were aware that this structure does depart from the precedent -- sounds like you are aware of that.
(originally from this forum post)
It looks like
RoboDK_getItemList
andRobodk_getItemListFilter
arevoid
functions, taking as argument a pointer to anint32_t
where the number of filled items will be stored.RoboDK_Selection
works similarly to thegetItemList
andgetItemListFilter
functions, but returns the number of filled items rather than taking a pointer to the number of filled items as an argument.In the interest of consistency, these three similar functions would ideally work the same: either all three would take a pointer or all three would return a value. It is more intuitive to me to return the number of filled items, like
RoboDK_Selection
does. However, I recognize that there are backwards-compatibility considerations that may make this challenging. It would be suboptimal to have to implement the following...