That seems like a tricky edge case, indeed. Not sure if this is a bug
either, or if there are any existing issues on github that covers this.
kl. 23:26:49 UTC+1 mandag 10. november 2014 skrev John Drummond følgende:
>
> Got it - I don't know whether it's a bug or not.
> if I comment out
> #import Base.isless
> in the LogParse.jl file and initially reload that in the repl and then
> reload the correct version with
> import Base.isless
> methods(isless) shows the method but sort says it's not defined, even when
> I specify it directly.
> Apologies for not checking the initial input in a fresh session, I thought
> that reloading a module would completely reload the functions, but
> presumably not when appending to those in Base.
>
> Kind regards, John.
>
>
>
>
> On Monday, November 10, 2014 6:04:29 PM UTC, John Drummond wrote:
>>
>> Thank you, that's helpful.
>> I reentered it all in a fresh session and found it working as well - I'll
>> try and find the difference which caused it not to work and come back.
>> Kind Regards, John.
>>
>> On Sunday, November 9, 2014 8:22:44 AM UTC, Ivar Nesje wrote:
>>>
>>> This code works everywhere I'm able to try it.
>>>
>>> kl. 03:18:13 UTC+1 søndag 9. november 2014 skrev John Drummond følgende:
>>>>
>>>> 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.
>>>>>>
>>>>>>