From: James Britt Date: 2004-12-30T10:41:45+09:00 Subject: Re: #send and private methods Brian Palmer wrote: > > In my mind, #send should honor the visibility of a method and only allow > calls to private methods if called like > > self.send("gets") > > But maybe there's a good reason for this behavior that I'm simply missing. Off the top of my head: Ruby is (almost) pure OO if that is what you want. And it behaves that way so long as you follow the OO conventions. And most Ruby developers do. However, it provides numerous hooks and inlets such that you can pretty much do as you like; the proverbial enough rope to shoot yourself in the foot. Why might this be? I would posit that programming languages exist to aid the developer, not the computer, and so should be enabling, not prohibitive. OOP|A|D is/are a set of design and development guidelines, not the Ten Commandments, so a language should not dictate, merely encourage. (Maybe even strongly encourage.) Any reasonably powerful language provides the wherewithal to write difficult, ugly, unreadable, unmaintainable, dangerous code. What stops most people from doing so is typically not the constraints of a language, but common sense and self-preservation. Using something like 'send' on private methods is similar to off-road driving. You can deliberately choose to step outside the boundaries, but you have to be responsible for your actions. Ruby treats you like an adult. James