Replies: 6 comments 5 replies
-
It is only allowed for structs and type aliases. Operator overloading in V is very limited and restricted, you have to return |
Beta Was this translation helpful? Give feedback.
-
Should be moved to discussion instead. |
Beta Was this translation helpful? Give feedback.
-
V already had some operator overloading: |
Beta Was this translation helpful? Give feedback.
-
So we can write generic functions that work whether they are used with built-in types or user defined types. |
Beta Was this translation helpful? Give feedback.
-
Thanks for all the answers, I agree that operator overloading is useful, but it should be strictly limited, and should be restricted to the language itself, with user customization forbidden, so that the meaning of each operator is made explicit, rather than meaning anything at all. Someone mentioned generic functions, and this is exactly what I was worried about. This is basically impossible to do if you look at the code that implements it every time. If all the code of the project is written by one person, such a problem seems less fatal. That's what I'm worried about. Operator overloading is sometimes a good idea. |
Beta Was this translation helpful? Give feedback.
-
Adding more restrictions to the existing : -, *, /, % : The parameter or the element of the parameter must be a number.
Maybe that's better? |
Beta Was this translation helpful? Give feedback.
-
CHANGELOG.md
V 0.2.2
Overloading of >, <, !=, ==, <= and >= operators.
I think this is a feature that would make the code look confusing.
When looking at other people's code it can make people wonder what "==" means now and if it has been overloaded.
The first word in the introduction of V is "simple", I hope it really is a simple language and not getting more and more complicated and finally becoming C++.
Beta Was this translation helpful? Give feedback.
All reactions