rune
rune copied to clipboard
Function attributes
I noticed the parser parses function attributes:
#[load(iterations = 1)]
pub async fn load(db, i) {
}
19 │ #[load(iterations = 1)]
│ ^^^^^^^^^^^^^^^^^^^^^^^ unrecognized function attribute
Is there a way to define them to make them recognized? I'd like to be able to provide some metadata in the embedded rune script that would be read by the host app.
Is there a way to define them to make them recognized?
Not at the moment. There's currently no hook to perform custom processing but all of it has to happen by the compiler.
I think there's two workflows to this: proc-macro like attributes, and information for the host. I'm wondering whether having a builtin #[meta(tag, key=value, ...)] could be enough for most things in the second group?
And then being some way of both querying for all things with a meta key, and some way of getting a specific function's meta... I guess it'd be a bit awkward in the above example, would need #[meta(load, iterations = 1)]; ... Unless we let LHS and RHS be anything that can be made a (const) value.
+1
I'd also find this feature really useful, for the second workflow stated above (information for the host), because it would provide a mechanism by which Rune script could advertise certain functions as being available to the host (provided the host also has a means of iterating them)