From: Jeff Date: 2010-01-13T11:11:34+09:00 Subject: Re: Using underscores for "private" instance variables? On Jan 12, 9:48 am, Gregory Brown wrote: > On Tue, Jan 12, 2010 at 10:33 AM, Jeff wrote: > > But I haven't seen anyone else need to do this in their modules/ > > classes, so now I'm wondering - has anyone else needed to do this?  It > > seems like this would be a common problem for any shared Ruby library, > > so now I'm wondering why I *haven't* run into this before. > > As things get sufficiently, complex, I think that something like this > might be reasonable.   Prawn is edging on needing some support for > avoiding name clashes, since it carries a lot of internal state in the > Document class and utilizes many mixins. > I'm not sure if this is the convention we'll use, but it's one possibility. Gregory, that's interesting. Maybe any Ruby library that reaches sufficent mass use will run into this problem. But I think the underscore doesn't really solve the problem, right? Let's say you use @_file in your module that I include. You probably use #nodoc# around it so I don't even see it in the rdocs. So then my class I'm about to do @file, but I think, someone might derive from my class, so I'd better call it @_file. Collision again. So I say, let's not use the hard-to-read underscores, and document ivars in the rdocs like everything else. Of course, it's not that I like my solution either... :-( I'm just not seeing how adding underscores solves the problem. Jeff