-
Notifications
You must be signed in to change notification settings - Fork 108
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
LIEK does not perform a deep copy #65
Comments
TLDR: lci doesn't seem to handle Bukkit inheritance quite right. There's a possible workaround (see below). ExplanationInteresting behavior indeed. I've dug into this a bit and here's what I've found. I believe lci was patterned after the Lolcode 1.3 proposal for Bukkits, so a rough explanation for how this should work can be found in the archived proposal.
Looking at your example program, it seems that lci is not completely following that last paragraph. It says that "If the variable name is found up the inheritance chain, then that variable is declared and created within the current object". Currently, if the variable name is found up the inheritance chain, then the variable is changed within the parent object. The code responsible for the assignment is in the updateScopeValue() function. The interpreter shares the same logic for updating nested scopes and Bukkits. Currently, the logic is correctly written for scopes but not for Bukkits. We may need to add Bukkit-specific logic to the function to handle updating inherited fields. WorkaroundIn the meantime, the tests in
|
Thank you for the explanation! That makes sense to me :) My usecase was to read input into an object with different fields, and then making a copy of that object so that I could have an unmodified copy and a working copy. Anyway, I have managed to copy without Enjoy the rest of your weekend! |
I expected
LIEK
to perform a deep copy of a BUKKIT type'd variable. It seems like it only copies the reference... which means there can only be one instance of mySOCIALCONSTRUCT
.Use Case: Store some state in an object, then duplicate that object in order to keep a backup of the state.
Behaviour: Modifying the copy also modifies the original
Workaround: Create a new
BUKKIT
(not the specific object, just a generic BUKKIT) and manually copy all the properties. The problem with that is the effort and that functions that would belong to the object have to be generalized.The text was updated successfully, but these errors were encountered: