One way to do it is

abstract Parent

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

For an example of this at larger scale, check out 
https://github.com/JuliaOpt/MathProgBase.jl/blob/master/src/MathProgSolverInterface.jl

On Monday, February 24, 2014 8:29:09 AM UTC-5, Joosep Pata wrote:
>
> Similarly, I have wondered what methods should an AbstractDataFrame 
> implement. Do we have a mechanism of specifying the interface of an 
> abstract type?
> 24.02.2014 15:00 kirjutas kuupƤeval "Johan Sigfrids" 
> <[email protected]<javascript:>
> >:
>
>> This is actually a really good question. I found myself wondering the 
>> same thing the other day.
>>
>> On Monday, February 24, 2014 1:54:59 PM UTC+2, andrew cooke wrote:
>>>
>>> Working on the finite field code I found myself asking "what is a 
>>> Number?".
>>>
>>> One answer is:
>>>
>>> julia> Base.subtypetree(Number)
>>> (Number,{(Complex{Float16},{}),(Complex{Float32},{}),(Complex{Float64
>>> },{}),(Complex{T<:Real},{}),(Real,{(FloatingPoint,{(BigFloat,{}),(
>>> Float16,{}),(Float32,{}),(Float64,{})}),(Integer,{(BigInt,{}),(Bool
>>> ,{}),(Char,{}),(Signed,{(Int128,{}),(Int16,{}),(Int32,{}),(Int64,{}),(
>>> Int8,{})}),(Unsigned,{(Uint128,{}),(Uint16,{}),(Uint32,{}),(Uint64,{}),(
>>> Uint8,{})})}),(MathConst{sym},{}),(Rational{T<:Integer},{})})})
>>>
>>> but that doesn't help so much.  What I really wanted to know is - what 
>>> methods are assumed to exist for something that is a subtype of Number?
>>>
>>> And I don't know how to answer that.
>>>
>>> Maybe (I don't think so) Julia needs some kind of concept like abstract 
>>> methods, where you can name methods for Number that any subtype must 
>>> implement?
>>>
>>> Maybe there needs to be some kind of tool that introspects the code base 
>>> and says "90% of subtypes define real and abs"?
>>>
>>> Maybe this has already been discussed or is clearly not an issue?
>>>
>>> Andrew
>>>
>>

Reply via email to