Steven, I'd say its just for the useful error message

e.g.

abstract Parent
method1(p::Parent) = error("Children must implement this or face an error!")
method2(p::Parent) = error("Children must implement this or face an error!")

type Child <: Parent
  fizz
  buzz
end
method1(c::Child) = println("happy days")
# no method2, naughty

user code
jimmy = Child(1,2)
method2(jimmy)  # Useful error message results that lets you know that you 
SHOULD be able to do this, but can't due to a failure to implement in 
library.



On Monday, February 24, 2014 10:27:16 AM UTC-5, Steven G. Johnson wrote:
>
> On Monday, February 24, 2014 9:55:33 AM UTC-5, Iain Dunning wrote:
>>
>> One way to do it is
>>
>> abstract Parent
>>
>> method1(p::Parent) = error("Children must implement this or face an 
>> error!")
>>>
>>>
>>>>>
> How is this better than just deleting the method1(::Parent) method, in 
> which case you will get a MethodError if one attempts to call it on a child 
> type?
>
>
>

Reply via email to