From: Cyent Date: 2005-05-07T09:09:23+09:00 Subject: Re: RCR 303: nil should accept missing methods and return nil On Fri, 06 May 2005 12:12:35 +0200, Robert Klemme wrote: > > I'm sorry, is this some kind of hoax? A program will not magically be > correct simply because an error is hidden. Think of all the subtle bugs > this would introduce, for example: you create an array with a fixed number > of elements and forget to give the default value 55. Now math would work, > but the results would be wrong - and you might not even catch this. Think of an array with 42 elements. Access element 55. It returns nil. How is this different? If you think through the default values for arithmetic operations on nil properly. My guess is the results in most case will be right.(How often do you initialize an array to 55? 99.9% of the time you expect it to be full of 0 or maybe 1. How about nil autoconverts to the identity element for all operations. ie. 0 for +, 1 for *, "" for string concat. In which case more code simplification, more code that just works. > The article at > http://www.smalltalkchronicles.net/edition2-1/null_object_pattern.htm that > you refer to in the RCR states, that it's a bad idea to introduce this > change in Smalltalk because it would break too much code. The situation in > Ruby is similar. Is it? I wwnt grepping through ruby 1.9 CVS (ok its a month or two old version) looking for some code that will break. I don't believe _anything_ will (currently) break. -- John Carter The Cybernetic Entomologist - cyent@xtra.co.nz http://geocities.yahoo.com/cy_ent I'm becoming less and less convinced of humans as rational beings. I suspect we are merely meme collectors, and the reason meme is only kept on to help count our change.