Skip to content

Extend at-specialize to force specialization of arguments #33978

@rfourquet

Description

@rfourquet

A trick currently used in Base (and probably elsewhere) to force specialization on functions is to artificially declare a type parameter, e.g. foo(f::F) where F = f(1). I would bet that the majority of Julia users don't know about this and would look at this piece of code without any idea about the role of F, and would even fix what appears as a naive use of type parameters by simplifying it to foo(f) = f(1).
What about adding some explicit means to this end, for example reusing @specialize: foo(@specialize(f)) = f(1) ?
xref: #33917 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions