From: dblack@... Date: 2007-09-04T05:34:22+09:00 Subject: Re: Ruby stupidities --1926193751-1914456425-1188851657=:28516 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-1914456425-1188851657=:28516" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-1914456425-1188851657=:28516 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Tue, 4 Sep 2007, Matthias W=E4chter wrote: > dblack@wobblini.net schrieb: >>> But certainly this may break existing libs, so be careful. >> >> The problem is, you can't be careful. You can only decide that it's OK >> for code to break, and keep your fingers crossed that it doesn't. > > Sure. Whenever you extend a basic class you take the risk of > breaking something. Choosing a name for a function or an alias when > you extend a function is nontrivial if you want to take into account > that the name can already be used. I guess what I wonder is: what does it mean to take that into account? If it affects our decisions, then we should always decide not to -- and all the more for actually changing the behavior of existing methods. >> I don't mean to split hairs -- of course "careful" can mean lots of >> things. It's just that I think it's important to remember that the >> code doesn't "know" that the person who changed it is worried :-) > > :) > >> It's >> just going to do what it does. So unless you're willing to read >> through the entire source code base, for Ruby and all add-on >> libraries, every time you make such a change, you're pretty much >> accepting some very real risk. > > I think that is what everyone who writes libraries has to do for > 1.9/2.0 anyway. I definitely don't discourage reading through the source :-) But it's very hard to check reliably to see (for example) whether there's any case where someone relies on the behavior of String#[], or gsub! returning nil, or whatever. And it could change.... I have to add that I'm just thinking out loud about things that have been tossed around for years -- it's not really a specfic critique of what you said, more that I've never quite understood what it actually *means*, in practical terms, when people say that one should be careful about making core changes, or not do it lightly, or "With great power comes great responsibility", etc. It's partly why I like #extend so much -- it limits the changes to individual objects. David --=20 * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com) --1926193751-1914456425-1188851657=:28516-- --1926193751-1914456425-1188851657=:28516--