Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bridge option which makes deep clones of objects instead of shallow clones #23

Closed
UnexomWid opened this issue Jun 22, 2020 · 0 comments
Assignees
Labels
added The requested feature was added approved The request or addition was approved feature Feature request or addition

Comments

@UnexomWid
Copy link
Owner

The local object is backed up before entering a loop, and restored after the end of the loop. Therefore, any changes done to the local object inside the loop should not propagate.

[|# local.x = 5 |]

[|@ iterator : array |]
    [|# local.x = 1 |]
[| end |]

The local object remains unchanged after the loop. However, not in this case:

[|# local.x = { value: 10 } |]

[|@ iterator : array |]
    [|# local.x.value = 5 |]
[| end |]

In this case, local.x.value becomes 5, due to the fact that the backup is done using shallow copy in order to favor performance.

An option should be added, such that deep cloning is used instead. Of course, this may lead to a significant performance drop, but it's still good to have such an option available in case it is needed.

@UnexomWid UnexomWid added feature Feature request or addition approved The request or addition was approved labels Jun 22, 2020
@UnexomWid UnexomWid self-assigned this Jun 22, 2020
@UnexomWid UnexomWid added the added The requested feature was added label Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
added The requested feature was added approved The request or addition was approved feature Feature request or addition
Projects
None yet
Development

No branches or pull requests

1 participant