Search code examples
julianumerical-methodsscientific-computingijulia-notebook

How to easily check the implementation of embeded functions in Julia language?


In Matlab, it is possible to check how (most?) of the embeded functions are implemented by typing edit function_name. The mentioned command open function_name code in editor.

I wonder if there's similar way in Julia language (for example how Cholesky's method has been implemented)?


Solution

  • Yes, there's the @edit macro call. You have to pass it a function call (not the function name) as it will open the right method. Example:

    @edit "a" * "string"
    

    opens the file /base/strings/basic.jl in line:

    (*)(s1::AbstractString, ss::AbstractString...) = string(s1, ss...)
    

    while

    @edit 1 * 2
    

    opens the file /base/int.jl in line:

    (*)(x::T, y::T) where {T<:BitInteger} = mul_int(x, y)
    

    To change the editor used, you can customize the environment variable "EDITOR". Example:

    ENV["EDITOR"] = "nano" 
    

    There is also the macro @less to print the function