Skip to content

RFC: Increase precedence of as #1717

@marijnh

Description

@marijnh

Right now, it has a lower precedence than the arithmetic operators, but I find that I almost always want to cast a single atomic expression, not the result of a binop. I.e. foo + (bar as uint) seems more common than (foo + bar) as uint. When I do need the second form, I usually end up parenthesizing the binop anyway, to aid readability.

So I think as should have a precedence higher than any of the binary operators. It'd make parsing simpler as well (moving parsing of casts into the function that handles calls, indices, etc, rather than having it be a special case in the binop parser).

Thoughts? What was the motivation for initially giving it its current precedence?

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