In Scala, I know that by typing private[this] we can make a private member only accessible by that particular object of the class, and another object of the same class cannot access it. If possible, how can we accomplish this in other languages... particularly F#, Erlang, and Clojure? Thanks.
type TestPrivate(x) = let y = x - 10 member private __.X() = 10 member __.Z() = x + 10 member __.Y = __.X() let test = TestPrivate(5) test.Z() //val it : int = 15 test.Y //val it : int = 10 test.X()
error FS0491: The member or object constructor 'X' is not accessible. Private members may only be accessed from wit hin the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda express ions.