Replies: 1 comment 6 replies
-
@Xyncgas it's unclear what you're asking for. Can you give an example? |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Records are immutable objects, currently if we want to modify the data we end up creating a new record
Say we have a simple record with
x
y
z
floating point values, we change x in a function and we end up with another record that has y and z copiedif we change y immediately after changing x, we can instead have
x
andy
modified while copying onlyz
to the new recordFor example, let
ModifyXY_A
beModifyXY_B
without creating a record from ModifyX only to be modified immediately by ModifyY even though ModifyX returns a record.While you may have a lot functions chained together / being called, it's combining all the functions into one function essentially to modify the record without even thinking about
ref
orstd::move
unless a function specifically depend on something modified by a previous function. IfModifyX
touched the field Y andModifyY
relies on it because it adds 1 to that value then yes we have something in the middle, but that may not necessarily be a record. We can put the immutable readonly record struct to a 'guarded' state while it now acts like a mutable struct but that's another story. IfModifyX
never touched the field Y thenModifyY
can now modify the record together withModifyX
Beta Was this translation helpful? Give feedback.
All reactions