Duplicating structs
-
Maybe it's not that advanced, but since it reguards memory managment i think it's not something the unexperienced people in programming and computers could understand.
I have noted that when you just declare a struct, equal to another previously declared one, this new struct behaves like a pointer to the first one, but when i change something suddenly after declaring it, it behaves as a proper duplicate.
Example code + more details:
fancyStruct = [.a = 1, .b = 54, .c = false, .d ={0,1,1,2}, .e = [23, 56, 34, 1223]] //The purpose of this second variable is to have a copy of the original state of the struct somewhere, to reset the first one regurarly before changeing it again. facncyerStruct = fancyStruct //now if i try to use fancyerStruct as is it will kind of behave like a pointer to the original struct, this happens while using it in a separated function called regurally with a timer, at least for the program i made fancyerStruct.c = true fancyerStruct.c = false //Doing something like this now makes this struct behave like it's own copy of the original struct, so when it's called ciclycally in the separated function, it will just be like a regular other sstruct separated from the original one
Now I don't know of it's intended to happen or it's just a bug, so i am here to ask you.
Are you able to recreate this? Have you seen similar issues?
If you want to take a look at the program in which i discovered this, you can send me a PM or look for the thread created by me in the work in progress section of the forum.
-
Thank you this @ITzTravelInTime
I've recreated the program exactly the same and it does appear that changing the copy of the struct also changes the original. This is not intended, and is indeed a bug.
I'll report this one now.