Replies: 1 comment
-
You are completely correct that using There is nothing that V can do about this. The functionality is there because it is truly necessary in some cases (such as interop with C and other languages), but many people are simply too lazy to do the correct thing, so they use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Many array functions have 'voidptr' type parameters,such as the insertion function:
pub fn (mut a array) insert (i int, val voidptr) {}
, you may think that the second parameter should be a pointer type, but in fact it can be passed in as either “array.data” or “array”, and it runs normally, but the result is very different. Just like the following code:out:
I think such function signatures are not intuitive and prone to ambiguity. Maybe it can be designed like this
pub fn (mut a array) insert [T] (pos int, arr [] T) {}
, I don't know if it's feasible. In short, I think it's necessary to set some explicit constraints to avoid a lot of unexpected behavior lurking in your code and breaking at any time.Beta Was this translation helpful? Give feedback.
All reactions