From: Bill Atkins Date: 2005-05-08T05:46:00+09:00 Subject: Re: Prove me Wrong! Re: RCR 303: nil should accept missing methods ------=_Part_5373_5200519.1115498739991 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline object =3D get_some_object # get_some_object returns nil object.perform_action_of_great_importance # action never gets performed - n= o=20 error On 5/5/05, John Carter wrote: >=20 > On Fri, 6 May 2005, Alexey Verkhovsky wrote: >=20 > > John Carter wrote: > > > >> A very simple and generic way of improving the reliability of Ruby > >> programs is to implement the NullObject pattern by allowing nil to > >> accept all and every method instead of throwing a NoMethodError. > > > > I, for one, would rather see it throwing an error as it is now. Dead=20 > programs > > don't tell lies. >=20 > I would suggest next 5 times you have a nil class throws > NoMethodError crash, just add this at the head of your program... >=20 > class NilClass > def method_missing( sym, *args) > nil > end > end >=20 > And see what happens. >=20 > If, your program then works correctly, then I am right. >=20 > If, your still program thows an exception or reports an error, but perhap= s > a slightly different point, then I am still right, namely this change > doesn't hide bugs. >=20 > If the program silent proceeds to do the wrong thing, then I am wrong. >=20 > I ask members of this list to actually try this experiment the next coupl= e > of times they hit a nil throws NoMethodError and send the results to me. >=20 > I will summarize to the list. >=20 > If I prove wrong, I will gladly retract my RCR and apologise. >=20 > John Carter Phone : (64)(3) 358 6639 > Tait Electronics Fax : (64)(3) 359 4632 > PO Box 1645 Christchurch Email : john.carter@tait.co.nz > New Zealand >=20 > This rock is covered by a very very thin layer of life. (Think 6000km > of rock followed by a meter or so of biomass.) >=20 >=20 --=20 Bill Atkins ------=_Part_5373_5200519.1115498739991--