Forum Discussion
EnTerr
10 years agoRoku Guru
"tar" wrote:
So it is like building on a sand then.
Interesting metaphor. Perhaps. Thus instead of a house - one has to build a houseboat, to make sure it won't sink?
Wait... 2nd worst mistake? Which one is the 1st?
The first most damaging to the developers at large i think is the choice of giving access to the fields with "." (dot-access is a shortcut to getField/setField). I am sure in theory it sounded cool - in practice though that sets a quicksand trap. Most people don't realize that on usage `node.field` does a deep-copy. You have probably discovered that but just in case, see viewtopic.php?f=34&t=95416 for a refresher.
And even after you know the dangers of dot-ing in RSG, it's un-intuitive which dot in the access chain A.B.C.D.E is the dangerous one. In your case `m.global.someImportantField`, the 1st dot is safe (since m is a regular dictionary). The 2nd dot may (or may not) be tricky, since that's a node (mine)field. If that field is another Node, it's safe - no copy. If it's an array or dictionary though, that gets copied first - with the side effect that if you do `m.global.myRoAssocArray.foo = "bar": ? m.global.myRoAssocArray.foo` - there will be no error but `m.global.myRoAssocArray` remains un-changed... mindfreak?