Replies: 2 comments 1 reply
-
I agree 💯 - that is an anti feature, or even a bug imho. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Can the receiver of the method have only two modes, fn (mut f Foo) and fn (f Foo), and the second can only be passing by reference mode, canceling passing by value mode? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the feature
This rule sounds as strange as possible, and what is most terrible, it is IMPLICIT and NOT DESCRIBED in the documentation.
I don't see the point in this rule because the developer can decide YOURSELF when the structure should be passed as reference or not.
Moreover, adding a new field to the structure completely changes the receiver's pass logic, which can be dangerous.
The compiler SHOULD NOT show off one's "intelligence" and add IMPLICITIES.
Example:
https://play.vlang.io/?query=06bda73b49 (8 fields)
All ok, different pointers because the receiver doesn't have a pointer type
https://play.vlang.io/p/88dc100004 (9 fields)
Not ok, same pointers.
Compiler code:
v/vlib/v/parser/fn.v
Line 646 in 865c0ea
Use Case
Proposed Solution
Remove this rule.
Other Information
No response
Acknowledgements
Version used
V 0.3.2 89aa695.865c0ea
Environment details (OS name and version, etc.)
Beta Was this translation helpful? Give feedback.
All reactions