Skip to content

Add alias statement #1113

Description

@TwitchBronBron

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:

  • aliases are scoped to the current file, and will not leak into the outer component or source scopes.
  • at transpile time, all referenced items will be transpiled using the original name (i.e. get2.aa() => get_aa())
  • alias name may not have the same name as an existing symbol.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions