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

AbstractMesh is just AbstractVector #54

Closed
rdeits opened this issue May 30, 2020 · 3 comments
Closed

AbstractMesh is just AbstractVector #54

rdeits opened this issue May 30, 2020 · 3 comments

Comments

@rdeits
Copy link

rdeits commented May 30, 2020

I'm working on porting MeshCat.jl from GeometryTypes to GeometryBasics, and I just ran into an interesting method ambiguity that turned out to be due to the fact that AbstractMesh is exactly AbstractVector:

julia> AbstractMesh
AbstractArray{Element,1} where Element

julia> AbstractMesh == AbstractVector
true

This makes it impossible to write a function that dispatches on a general AbstractVector vs. an AbstractMesh. It also means that any function written for an AbstractMesh is actually claiming to support any kind of vector of any element, which seems wrong.

It's not a blocker for my work, but I think it's likely to be a minor source of annoyance going forward. Would it be possible to put some kind of type restriction on the element of AbstractMesh? Anything more restrictive than Any would fix the issue and make AbstractMesh a usable type.

@rdeits
Copy link
Author

rdeits commented May 30, 2020

Or, if determining a meaningful element type restriction is hard, what about doing:

abstract type AbstractMesh{Element} <: AbstractVector{Element} end

which would fix the root issue without limiting the possible element types.

@Sov-trotter
Copy link
Contributor

I am working on a similar thing for Shapefile.jl JuliaGeo/Shapefile.jl#39
And while creating a type for MultiPatch type, that is actually a Mesh, realized that GB doesn't currently have a metatype for Mesh types. So I tried to write one similar to the one here #52
Something like this, @meta_type(Mesh, mesh, AbstractVector, P) and it works. So doesn't that automatically suggest, AbstractVector supertypes Mesh type?

@SimonDanisch
Copy link
Member

Oh, I thought I'm restricting the Element type... That's definitely bad :D Also, 99% of the methods should like use Mesh for typing the arguments

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

No branches or pull requests

3 participants