Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function attributes #293

Open
pkolaczk opened this issue Nov 7, 2021 · 4 comments
Open

Function attributes #293

pkolaczk opened this issue Nov 7, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@pkolaczk
Copy link
Contributor

pkolaczk commented Nov 7, 2021

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.

@udoprog
Copy link
Collaborator

udoprog commented Nov 8, 2021

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.

@udoprog udoprog added the enhancement New feature or request label Nov 8, 2021
@tgolsson
Copy link
Contributor

tgolsson commented Nov 8, 2021

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.

@jasal82
Copy link

jasal82 commented Mar 3, 2023

+1

@jbrd
Copy link

jbrd commented Sep 8, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants