Skip to content

Defining multiple interfaces for one type #55

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

Open
ReubenJ opened this issue Feb 22, 2025 · 3 comments · May be fixed by #56
Open

Defining multiple interfaces for one type #55

ReubenJ opened this issue Feb 22, 2025 · 3 comments · May be fixed by #56

Comments

@ReubenJ
Copy link

ReubenJ commented Feb 22, 2025

The docs for @implements mention the ability to define a type as inheriting from multiple interfaces by supplying a vector of interfaces, but it appear that the macro only handles the cases: Interface{:option} or plain, single Interface.

Am I missing something?

The docstring mentioning it:

The macro can only be used once per module for any one type. To define
multiple interfaces a type implements, combine them in square brackets.

The logic for handling the interface argument to the macro:

if interface isa Expr && interface.head == :curly
interfacetype = interface.args[1]
optional_keys = interface.args[2]
# Allow a single Symbol instead of a Tuple
if optional_keys isa QuoteNode
optional_keys = (optional_keys.value,)
end
else
interfacetype = interface
optional_keys = ()
end

Thanks for your work on this package! Really appreciate the thought going into it.

@ReubenJ ReubenJ changed the title Defining multiple interfaces Defining multiple interfaces for one type Feb 22, 2025
@rafaqz
Copy link
Owner

rafaqz commented Feb 23, 2025

I think the doc is just old and wrong. You can call @implements for multiple interfaces with the same object.

@ReubenJ
Copy link
Author

ReubenJ commented Feb 24, 2025

Got it. Seems like an easy thing to support, right? I could make a quick PR for it if you like.

@rafaqz
Copy link
Owner

rafaqz commented Feb 24, 2025

I may be cleaner just to do separate calls? I'm ok with needing one line per interface.

@ReubenJ ReubenJ linked a pull request Feb 26, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants