Skip to content

[Docs] Getting Started #80

@ptoche

Description

@ptoche

CodeTracking [...] provides an interface for obtaining:

the strings and expressions of method definitions

How does CodeTracking do the above?

using CodeTracking, Revise

f = x -> 2 * x^3 + 1

julia> @code_expr f
ERROR: LoadError: expression is not a function call or symbol

julia> @code_string f(1)
ERROR: LoadError: MethodError: no method matching getindex(::Nothing, ::Int64)

julia> print(@code_expr f(1))
nothing 

I did not post on discourse because there are existing discussions and unfortunately I haven't been able to understand them. Can the above be done? If so, an example would be greatly appreciated. I'm opening an issue, so perhaps a word or two could be added to the readme. I won't be offended if you close it. :-)

Comments in these discussions point to CodeTracking, but unfortunately do not show examples of usage:

https://discourse.julialang.org/t/source-code-of-a-function/4499/12

https://discourse.julialang.org/t/printing-the-body-of-a-defined-function/23439/2

https://discourse.julialang.org/t/show-code-macro/46050

Discussion where the plot thickens:

https://discourse.julialang.org/t/get-function-as-expr/51886/5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions