On 05/10/2005 02:35 AM, mark sparshatt wrote:
> Dr Balwinder S Dheeman wrote:
> 
>> On 05/09/2005 10:19 PM, Bill Atkins wrote:
>>
>>> What does that show?
>>>
>>> On 5/9/05, Dr Balwinder S Dheeman <bsd.SANSPAM / cto.homelinux.net> wrote:
>>>
>>>> On 05/09/2005 04:21 AM, Bill Atkins wrote:
>>>>
>>>>> This isn't about changing programming habits.  Having nil return nil
>>>>> for missing methods can have serious consequences.
>>>>>
>>>>> Consider:
>>>>>
>>>>>   file = create_new_log_file
>>>>>   file.log "here's a bit of information"
>>>>>
>>>>> You're expecting this code to log something to a file every time it
>>>>> gets called.  But suppose create_new_log_file returns nil, due to some
>>>>> mistake you've made while coding it.  No exception is raised, so when
>>>>> you run your program, it performs its job appropriately.  You move on.
>>>>>
>>>>> Two months later, you urgently need to get information from those
>>>>> logs.  But uh-oh - the log files are empty.  Now you're screwed.
>>
>>
>>
>> Why two months later? If your method 'create_new_log_file' returns 
>> nil, i.e saved in 'file', an exception 'NoMethodError' is raised for 
>> undefined method 'log' for nil:NilClass which clearly is 'file' in 
>> your example above.
>>
>> What do you want to prove? otherwise?
>>
> I think the point that Bill Atkins is trying to make is that if RCR 303 
> is accepted then an exception won't be raised, and so he won't discover 
> the error till he actually looks at the log file.

Ok, Bill Atkins is right. There is no point is accepting such an RCR, 
which not only is a wrong proposal, but will also break backward 
compatibility if accepted.

>>>> irb(main):001:0> file.log 'here is a bit of infromation'
>>>> NameError: undefined local variable or method `file' for main:Object
>>>>         from (irb):1
>>>> irb(main):002:0> file = nil
>>>> => nil
>>>> irb(main):003:0> file.log 'here is a bit of infromation'
>>>> NoMethodError: undefined method `log' for nil:NilClass
>>>>         from (irb):3
>>>> irb(main):004:0>

-- 
Dr Balwinder Singh Dheeman            Registered Linux User: #229709
CLLO (Chief Linux Learning Officer)   Machines: #168573, 170593, 259192
Anu's Linux@HOME                      Distros: Ubuntu, Fedora, Knoppix
More: http://anu.homelinux.net/~bsd/  Visit: http://counter.li.org/