Skip to content

Marking var"#self#" as stable? #58908

@MilesCranmer

Description

@MilesCranmer

Just wondering if this keyword could be marked stable API? Or, for example, if there could be a macro such as @__SELF__ or @__FUNCTION__ that is exported and gets aliased to it?

I have found this symbol to be a life saver for writing macros in DispatchDoctor.jl as I need to generate self-referential functions. When used on a closure function, there is really no way to avoid boxing and type instabilities other than to use var"#self#". At this time it seems the only downside is that it's not marked as stable, so I was wondering if this could be done.

The symbol isn't used that much in the ecosystem: https://github.com/search?q=language:julia%20/var%22%23self%23%22/&type=code. Though I wonder if this is simply because it's not well known (I only discovered it today from https://discourse.julialang.org/t/recursive-closures-inner-functions-how-to-avoid-boxing/124758/7).

I think it's really nice to have this as a complement to @__FILE__, @__MODULE__, etc., but for referring to the current function name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureIndicates new feature / enhancement requestsmacros@macros

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions