Open ghaith opened 7 months ago
I think changing the error message for missing compare functions would also be quite helpful for the user, to make clear that they are expected to implement these themselves/provide their own logic for how they want them compared.
We need to support some kind of comparison possibilities when it comes to arrays. See discussion below
For context, making a default struct comparison function is not a trivial task, and often also not something the user wants of a language. The difficulty is to decide what fields in a struct are relevant for a comparison, this is why in other languages you see the struct comparison always implemented by the user and not offered by the language. So for structs there is already a solution in place that we can't make better imho which is that the user implements a comparision function for the struct. If we provide a default one based on memcmp in the standard functions we will bind it with a warning. But I think at least for structs and array types that are declared in Datatypes the solution is implement the function yourself, this is what the error suggests :
For arrays that are not declared in types we would have to provide a method that either calls memcmp which is problematic, or a deep equals method which is slow. Maybe we could also just give that to the user as int ARRAY_EQUALS function to implement and they can decide if they want deep equals or not depending on the datatype they have.
Originally posted by @ghaith in https://github.com/PLC-lang/rusty/discussions/1050#discussioncomment-8217546