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

type signatures #22

Closed
mkborregaard opened this issue Nov 6, 2019 · 5 comments · Fixed by #89
Closed

type signatures #22

mkborregaard opened this issue Nov 6, 2019 · 5 comments · Fixed by #89

Comments

@mkborregaard
Copy link
Member

Hi, the droptips function appears to have the signature droptips!(t::T, tips::Vector{NL}) where {NL, BL, T <: AbstractTree{NL, BL}}. But couldn't tips be any AbstractVector{NL}, or be a Set{NL}? Or a generator or an Iterator or anything else that yields something that can be interpreted as a Node?

@richardreeve
Copy link
Member

Yes, absolutely. Good point.

@mkborregaard
Copy link
Member Author

Simply delete the type signatures, and duck type on anything but AbstractTree? Or is the NL important?

@richardreeve
Copy link
Member

#20 does switch it to AbstractVector{NL} already incidentally. We could duck type, but I'd rather wait until we have a sensible trait interface and then just put in some iterable trait. If you have a need for a Set or something that's not an AbstractVector I'm happy to switch it now though...

@mkborregaard
Copy link
Member Author

I don't need a Set very much - that's just the type I naturally had in my code when I ran into this. AbstractVector{NL} is probably OK but why not just ducktype, where do you see the issue?

@richardreeve
Copy link
Member

I'm just not a massive fan of duck typing, partly unfairly because the languages where I've used it tend to be so poorly designed (though I appreciate that's not the case here), but also because the errors when you misjudge the (now hidden) type requirements are that much more obscure as they are buried in some subsidiary function call. I'm not implacably opposed to it though - I'll sort it out.

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