I was originally julia 0.3.1 on windows 7
this is on Macosx 10 julia 0.3.2
I loaded the file LogParse.jl below and then in the repl ran

reload("LogParse.jl")

methods(isless)


ary1 = LogParse.DayPriceText[]
push!(ary1,LogParse.DayPriceText(4,"a1",1))
push!(ary1,LogParse.DayPriceText(2,"a1",1))
push!(ary1,LogParse.DayPriceText(6,"a1",1))


sort(ary1)

sort(ary1,lt=LogParse.isless)
I get the same messages - methods(isless) shows that it's loaded
but the sort can't find it, even when I try to specify the function


#in file LogParse.jl ###########
module LogParse
export DayPriceText
import Base.isless

type DayPriceText
  a1::Uint32
  b1::ASCIIString
  a2::Uint32
end

function isless(a::DayPriceText, b::DayPriceText)
  if (a.a1 < b.a1)
    return true
  else
    return false
  end
end


end
######

Many thanks.
Kind regards, John


On Friday, November 7, 2014 7:34:40 PM UTC, Ivar Nesje wrote:
>
> In this case it would be really great if you had a minimal reproducible 
> example. It looks to me as you are doing everything right, so I would start 
> looking for typos and scoping issues. It's hard to find them without 
> looking at the code.
>
> Ideally the example should be small and possible to paste into a REPL 
> session, but if you can publish your code and don't want to extract only 
> the relevant part, that might be fine too.
>
> Julia version and operating system is also nice to include, so that we 
> have it available in case we have problems reproducing your results.
>
> Regards Ivar
>
> kl. 20:14:48 UTC+1 fredag 7. november 2014 skrev John Drummond følgende:
>>
>> Hi,
>> I suspect I'm doing something stupid but no idea what I'm missing.
>>
>> I create a module .
>> I create a type in it, DayPriceText
>> I import Base.isless
>> I define isless for the type
>>
>> now in the repl I get
>>
>> methods(isless)
>> =>
>> # 25 methods for generic function "isless":
>> ......
>> isless(x::DayPriceText,y::DayPriceText) at 
>> c:\works\juliaplay\LogParse.jl:16
>>
>> but
>>
>> julia> typeof(a1p)
>> Array{DayPriceText,1}
>>
>> julia> sort(a1p, lt=CILogParse.isless)
>> ERROR: `isless` has no method matching isless(::DayPriceText, 
>> ::DayPriceText)
>>  in sort! at sort.jl:246
>>
>> julia> sort(a1p)
>> ERROR: `isless` has no method matching isless(::DayPriceText, 
>> ::DayPriceText)
>>  in sort! at sort.jl:246
>>
>> I'm sure there's some obvious answer, but I've not idea what.
>> Thanks for any help
>> kind regards, John.
>>
>>

Reply via email to