dsimcha wrote:
Regarding recent discussions in Bugzilla:  I wonder if we could somehow define
a super-efficient struct opEquals that performs introspection and only tests
expensive members if it's necessary.

The compiler should be doing this. It's the way to fix the Bugzilla bug.
There should be no need to define opEquals() unless it does something different to an element-by-element comparison.

Of course, we could get even fancier.  We could recursively introspect struct
types and use various heuristics to calculate the optimal comparison order at
compile time.  Similar stuff could be done for a generic opCmp that gives a
struct an arbitrary total ordering as long as all of its members have a total
ordering.

Yes. This is something the compiler can't (or shouldn't) do.

Reply via email to