Skip to content

Inline multi-line functions #397

@mkruselj

Description

@mkruselj

Let's say we have a function like:

function math.clamp(x, min, max)
    if (x < min)
        x := min
    else if (x > max)
        x := max
    end if
end function

We currently cannot inline this function in cases like these (or at all, really - cannot even assign such a function to a variable directly):

if math.clamp(x, 0, 100) = 50

What would need to happen is:

temp := math.clamp(x, 0, 100)

if temp = 50

There would have to be a proxy variable for every expression that is bool'd together. Probably makes sense to use an array instead.

if math.min(x, 0) # 0 and math.clamp(y, 0, 100) = 50

becomes:

temp[0] := math.min(x, 0)
temp[1] := math.clamp(y, 0, 100)

if temp[0] # 0 and temp[1] = 50
    <code>
end if

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions