Break OO privacy: Difference between revisions

no edit summary
(+OCaml. Please forgive me.)
No edit summary
Line 691:
X = 3
true</lang>
 
=={{header|M2000 Interpreter}}==
We want to read two private variables, and change values without using a public method (a module or a function), and without attach a temporary method (we can do that in M2000). There is a variant in READ statemend to set references from group members (for variables and arrays, and objects) to names with a reference for each. So using these names (here in the exaample K, M) we can read and write private variables.
<lang M2000 Interpreter>
Module CheckIt {
Group Alfa {
Private:
X=10, Y=20
Public:
Module SetXY (.X, .Y) {}
Module Print {
Print .X, .Y
}
}
Alfa.Print ' 10 20
\\ we have to Konw position in group
\\ so we make references from two first
Read From Alfa, K, M
Print K=10, M=20
K+=10
M+=1000
Alfa.Print ' 20 1020
}
CheckIt
</lang>
 
=={{header|Nim}}==
404

edits