On Tue, Aug 11, 2015 at 4:42 PM, Jared Crean <[email protected]> wrote:
> Thanks for the quick reply.
>
> Now I am curious, what happens if the old method was inlined in a function
> compiled before the new method was created.  It must continue to use the old
> method, right?  What if the function was not inlined?
>
> for example:
>
> mat = # create SparseMatrixCSC here
> function calcSomething(A::SparseMatrixCSC)
>    x = A[i,j] + 1
>    ...
> end
>
> calcSomething(mat)
>
> function getindex(A::SparseMatrixCSC, i, j)
>   # define new getindex here
> end
>
> calcSomething(mat)  # what happens?
>
>
> I understand that overriding methods in Base is playing with fire...

Currently basically an undefined behavior.
https://github.com/julialang/julia/issues/265

>
>   Jared Crean
>
> On Tuesday, August 11, 2015 at 4:28:05 PM UTC-4, Yichao Yu wrote:
>>
>> On Tue, Aug 11, 2015 at 4:00 PM, Jared Crean <[email protected]> wrote:
>> > For a problem I am working on, I need to be able to store explicit zeros
>> > in
>> > a SparseMatrixCSC.  While the storage format supports this, the
>> > setindex!
>> > method does not. Also, for banded sparse matricies I can define a much
>> > more
>> > efficient getindex method than the generic one.  When I define my own
>> > method
>> > (importing the one from Base and then creating a method with the same
>> > signature as the existing one) I get warnings of the type:
>> >
>> >
>> > Warning: Method definition
>> > getindex(Base.SparseMatrix.SparseMatrixCSC{#T<:Any, Ti<:Integer},
>> > Integer,
>> > Integer) in module SparseMatrix at sparse/sparsematrix.jl:1232
>> > overwritten
>> > in module PDESolverCommon at
>> > /users/creanj/.julia/v0.4/PDESolverCommon/src/sparse.jl:63.
>> >
>> > My question is in what contexts is the method overwritten?  In my local
>> > context (the REPL session where I use the one I created).  Do functions
>> > within Base use the one in Base or the local one?
>>
>> Every user of it (including Base) in your current julia session.
>>
>> >
>> > Jared Crean
>> >
>> >

Reply via email to