rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
159 stars 46 forks source link

Add alias statement #1113

Closed TwitchBronBron closed 4 months ago

TwitchBronBron commented 6 months ago

Add an alias statement to the language. This will provide a workaround for shadowed items.

Consider this example. Due to the namespace-relative functionality, the get method found on line 22 is the outer get function on line 21. However, we wanted to call get.aa() from line 27. We currently have no way to work around this.

image

That's where the alias statement comes in. It allows declaring a new name for an existing symbol.

alias get2 = get

namespace http
    'Do an HTTP request
    sub get()
        print get2.aa() 'using `get2` aliased symbol here. it's now clear which item we intended to use
    end sub
end namespace

namespace get
    function aa()
    end function
end namespace

Criteria: