Support default values inside of generated DependencyEndpoint function parameters #246
ollieatkinson
started this conversation in
Ideas
Replies: 1 comment 4 replies
-
@ollieatkinson Thanks for sharing the idea! While default arguments would be a nice feature to support, I think we would want such support to leverage existing Swift features and the type system. I think generating code from comment declarations might be difficult to get right and provide good diagnostics for. No alternatives come to mind, but we're open to further discussion if you have any. At the end of the day, manually defining the occasional method that needs a default isn't so bad, and seems better than relying on too much macro magic. What do you think? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When using DependencyEndpoint we specify that an associated function must be generated to help with ergonomics of using the dependency, in this, we provide the name and type of each parameter so the macro is able to generate the function.
💡 It would be nice if we were also able to provide some syntax to allow the generated function to include default values for the parameter.
expands to
I do not have much experience with SwiftSyntax to know how we can implement this, open to feedback on the idea, syntax and help on approach to implemention.
Beta Was this translation helpful? Give feedback.
All reactions