Skip to content

new syntax for attributes #25502

@StunxFS

Description

@StunxFS

Describe the feature

Currently, attributes are simply a label that can accept a simple value: atribute: value, but this syntax is somewhat limited. My idea is that instead of using a simple label that can accept a simple value, we use a syntax similar to that for function calls: atribute(argument).

Use Case

The idea came up while reviewing PR #25480, a possible solution would be to use this new syntax to unify the deprecated attribute:

@[deprecated('use ultimate_fn instead', after: '2025-10-10')]
fn super_fn() {}

fn ultimate_fn() {}

Proposed Solution

This new attribute syntax could behave just like a function call, allowing positional arguments as well as named arguments.

@[unsafe]
@[deprecated]
@[deprecated('use new module instead')]
@[deprecated(msg: 'use new module instead', after: '2025-10-10')]

Attributes that do not take arguments may ignore ().

Also, the user (and even the compiler itself in the builtin module) could define attributes using the following syntax:

@[atribute]
fn deprecated(msg string, after string)

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

latest

Environment details (OS name and version, etc.)

all

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions