-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
@nameOf built in function #8270
Copy link
Copy link
Closed as not planned
Labels
proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.This issue suggests language modifications. If it also has the "accepted" label then it is planned.
Milestone
Description
Activity
Metadata
Metadata
Assignees
Labels
proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.This issue suggests language modifications. If it also has the "accepted" label then it is planned.
Proposal
Introduce a new built-in function
@nameOfthat returns the name of any declaration (fields, functions, variables, consts, etc) as acomptime []const u8.Motivation
Even with most of
comptimestrings being capable of raise compiler errors, strings are not easily trackable/refactorable when the underlying declaration changes. Many IDEs have some sort of feature allowing automated code-refactoring, which would be hard to use against strings.Simple example
Drawbacks
As a built-in function,
@nameOfmust be capable to accept expressions that aren't valid in normal statements, for example:Similar behavior is observed in C#'s nameOf operator.