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

Use Base.Callable instead of Function in signatures #128

Merged
merged 1 commit into from
Dec 21, 2020

Conversation

cmcaine
Copy link
Collaborator

@cmcaine cmcaine commented Dec 20, 2020

It's probably a better idea?

@hustf
Copy link

hustf commented Dec 20, 2020

A slightly off-topic comment here:

I actually didn't know that the more general Callable existed at all, but I suppose it includes types, which are callable with an argument. If Callable is usefully more general, perhaps more function argument types should be elevated? What's a more general use case than Function?

Mux has a short and elegant codebase which I don't know well at all. One area of potential improvement (which would have been helpful in the past) could be tracing errors. I found this (from websockets) to be useful when condensing error messages:

function _show(io::IO, f::Function)
   m = methods(f)
   if length(m) > 1
       print(io, f, " has ", length(m), " methods: ")
       Base.show_method_table(io, m, 4, false)
   else
       method = first(m)
       argnames = join(method_argnames(method)[2:end], ", ")
       print(io, method.name, "(", argnames, ")")
   end
end

@cmcaine
Copy link
Collaborator Author

cmcaine commented Dec 20, 2020

Base.Callable is just Union{Function, Type}, I think the general advice is not to dispatch on either :)

Thanks for the advice about errors, I'm still wondering how we might handle them better in Mux.

@cmcaine cmcaine merged commit 83155af into JuliaWeb:master Dec 21, 2020
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 this pull request may close these issues.

3 participants