Skip to content

Allow statically typed variables #71

@cscherrer

Description

@cscherrer

The Julia docs recommend that in some cases, variables can be type-annotated (LHS, not RHS). The section
https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-captured
says,

If captured variables are used in a performance-critical section of the code, then the following tips help ensure that their use is performant. First, if it is known that a captured variable does not change its type, then this can be declared explicitly with a type annotation (on the variable, not the right-hand side):

function abmult2(r0::Int)
    r::Int = r0
    if r < 0
        r = -r
    end
    f = x -> x * r
    return f
end

Annotations like r::Int = r0 sometimes lead to problems if GG also decides to box that variable. Could a type declaration like this be taken by GG as an assertion that the variable is unboxed?

This is related to cscherrer/Soss.jl#337

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