push! it is then. I will write on the JuliaGeometry repo what I am doing.
On Monday, March 16, 2015 at 2:30:32 PM UTC+1, Simon Danisch wrote: > > I'm very much in favor of overloading, if the meaning doesn't deviate to > much. > Like this, you don't have to read any documentations, and the base > functions become synonymous with a certain task. > So if you want to add an element to some object, first thing you can try > is to use push! and if that works, you are not forced to look up the > documentation for that datatype. > > By the way, it seems you're developing a mesh type. I still hope to unify > mesh representation, which is admittedly not the simplest task. > Maybe you can take inspirations from JFineale > <https://github.com/PetrKryslUCSD/JFinEALE.jl>, Meshes > <https://github.com/JuliaGeometry/Meshes.jl>, Meshes2 > <https://github.com/JuliaGeometry/Meshes2.jl>, MeshIO > <https://github.com/JuliaIO/MeshIO.jl> and take part in the discussion in > JuliaGeometry <https://github.com/JuliaGeometry/meta>. > Would be a shame, if everyone writes their own code and in the end, it all > doesn't work together. > This is especially important for a unified visualization infrastructure. > > Am Montag, 16. März 2015 14:11:54 UTC+1 schrieb Kristoffer Carlsson: >> >> Simple example. Let's say I have the type >> >> type Mesh >> elements::Vector{Element} >> node::Vector{Node} >> end >> >> and I want to add functions to add elements or nodes. I could either do >> this by overloading push! like this: >> >> push!(mesh::Mesh, elem::Element) = push!(mesh.elements, elem) >> >> or add a new method >> >> addelement(mesh::Mesh, elem::Element) = push!(mesh.elements, elem) >> >> I know code where operators are heavily overloaded can be difficult to >> read however, this case seems quite simple. >> >> Anyone have any advice for which way to prefer? What is more Julian? >> >> Best regards, >> Kristoffer Carlsson >> >>
