Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Adds support for :decorators in anon fns, defasync #1189
Adds support for :decorators in anon fns, defasync #1189
Changes from 1 commit
3ee87e9
5e47062
821213a
55c02ce
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the correct order for how it is done in Clojure? I am indifferent towards the order, but I'd rather not have another ticket later just because it's wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very interesting point I did not consider.
To clarify, I believe you are asking about the merging order: should the fn
name
metadata override theform
(fn-decl
) metadata? Specifically, should the fnname
metadata key:decorators
take precedence over the:decorators
key in theform
metadata?From a quick survey:
defn
behavior: Both Clojure and Basilisp pass metadata to thefn
functionname
.fn
behavior: Thefn
definition uses metadata keys from theparams
vector only for:pre
and:post
conditions.Thus based on the above, there’s no defined precedence in Clojure between fn
form
andname
metadata. This leaves the choice up to us.For the
fn
form, there are three potential places for the:decorators
metadata key:form
itself, i.e.^{:decorators [...]} (fn ...)
).name
(if provided), i.e.(fn ^{:decorators [...]} name ...)
.params
, `(fn ^{:decorators [...]} [param1 ...] ...)Since
defn
passes its metadata to the fnname
(option 2), this seems like a strong candidate for support. Conceptually,:decorators
are tied to the function, so supporting theform
metadata key (option 1) also makes sense.Conceptually to me, decorators are linked to the function, so I think support for the key in the
form
metadata should also be supported.If both are supported, my view is:
name
metadata key should take precedence over theform
metadata key.fn
form is more targeted than metadata outside it (but I think you can also equally argue in the opposite direction 😅)Supporting
params
metadata (option 3) would also be possible, but it complicates precedence rules unnecessarily.I prefer supporting both
form
andname
metadata keys, with precedence given to the fnname
key. Alternatively, for simplicity, we could support only theform
metadata key.What is your view?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we should support
form
andname
with preference forname
metadata.