Honour
MModular
•Created by Honour on 9/10/2023 in #questions
unable to pass by value
@TeamPuzel @guidorice perhaps you guys have misunderstood me . consider the code below
the compiler complains if you try to modify x inside the copy function because its not mutable, right??. The only way to provide mutability is with the
inout
keyword, but inout
automatically makes x
a mutable reference, which means modifying it also modifies the the original variable.
my point is that primitive types like int should copy by default or atleast allow the programmer to decide if they want a mutable reference
or a mutable copied value
28 replies
MModular
•Created by Honour on 9/10/2023 in #questions
unable to pass by value
yeah it says value-semantics in the docs but then i created a
def
function with an Int argument and when i hover over it with the cursor the function signature says owned Int
which means it just transfers ownership rather than copy it28 replies