Skip to content

Consider implementing equals and hashCode for value classes #7

@jcuda

Description

@jcuda

There are several classes in JCuda that can be considered as "value classes": Plain old data structures that are direct ports of the structs in C, using only public fields.

In #6 it was proposed to add equals and hashCode implementations to (one of) these classes.

While it might be appropriate and in line with certain usage patterns in Java, it might distort the semantics in other cases. Some of these value classes contain Pointer objects, which may make an appropriate implementation of equals and hashCode difficult and involve subtle caveats.

For now, the trade-off between usefulness and possible caveats for me seems to be in favor of not implementing these methods. One could also say that the C structs are not C++ classes and do not overload the == operator - and even less are considered to be used as keys in an unordered_map. However, I'll leave this issue here open for comments, until a final decision is made.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions