Question about UDAs
Adam D. Ruppe
destructionator at gmail.com
Mon Aug 3 03:13:02 UTC 2020
On Monday, 3 August 2020 at 03:00:08 UTC, Cecil Ward wrote:
> When practically speaking would you use UDAs? A real-world
They are useful when you want to attach some kind of metadata to
the declarations for a library to read. For example, my script.d
looks for `@scriptable` for methods that it should expose to the
script user. My cgi.d uses things like `@URLName("foo")` and/or
`@DisplayName("whatever")` if you want to override the
auto-wrapper's default strings.
My day job work project uses it for user-visible documentation of
their functions too, accessible from a command line interface.
> I’ve seen them in use already for core language features
> instead of keywords like "pure"
i wouldn't call those UDAs because they aren't user-defined...
but yeah it is the same syntax there basically too.
More information about the Digitalmars-d-learn