Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Alias Statement #1151

Merged
merged 14 commits into from
May 6, 2024
Merged

Adds Alias Statement #1151

merged 14 commits into from
May 6, 2024

Conversation

markwpearce
Copy link
Collaborator

This is pretty cool!

alias provides a way to work around variable name shadowing... but as a side effect, it also give a way to shorthand just about any property/function you want.

alias get2 = get

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

namespace get
    function aa()
        return {
            data: "abc"
        }
    end function
end namespace

transpiles to

sub http_get()
    print get_aa().data
end sub

sub get_aa()
    return {
        data: "abc"
    }
end sub

it also allows this ... which is cool?:

alias lc = lcase
alias co = createObject

sub getModelTypeLower()
   lc(co("roDeviceInfo").getModelType())
end sub

it also allows this ... which is also cool?:

alias abgdz = alpha.beta.gamma.delta.zeta

sub foo()
   print abgdz.someConst
end sub

@markwpearce markwpearce added this to the v1.0.0 milestone May 2, 2024
@markwpearce
Copy link
Collaborator Author

addresses #1113

Copy link
Member

@TwitchBronBron TwitchBronBron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just a few small things

docs/variable-shadowing.md Outdated Show resolved Hide resolved
src/DiagnosticMessages.ts Outdated Show resolved Hide resolved
src/files/BrsFile.spec.ts Show resolved Hide resolved
@markwpearce
Copy link
Collaborator Author

Updated to fixes review comments.

@markwpearce markwpearce requested a review from TwitchBronBron May 6, 2024 12:32
@TwitchBronBron TwitchBronBron merged commit bb0d81d into release-1.0.0 May 6, 2024
6 checks passed
@TwitchBronBron TwitchBronBron deleted the alias_statement branch May 6, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants