C++ Logo


Advanced search

Re: Colony/hive & unordered vs ordered == operator

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Tue, 15 Mar 2022 16:41:45 +0200
On Tue, 15 Mar 2022 at 15:45, Henry Miller via SG14
<sg14_at_[hidden]> wrote:
> The more I think about this the more convinced I become that hive should not have operator== at all.

Agreed. My rationale is thus:

- I would think two hives are equal if they contain the same bees
- that's an unordered operation, because hive is unordered
- yeah, sure, a hive is ordered if you don't remove and re-add bees,
because their positions-once-inserted-but-not-removed in the hive
are stable, but that's a stretch of the semantics, if you ask me; all
use cases of hive, as far as I understand
them, are geared for scenarios where the user must not care about the
order of the hive, just that it either
does or does not contain a particular bee.

Then we get to the semantics and cost of the unordered equality
comparison, and we come to the conclusion
that it's perhaps something that shouldn't be provided as an equality
operator at all. The need to allocate memory
instantly calls for domain-specific customizations, and to cater for
those we need a function anyway, and we should
perhaps standardize such functions only if we find really really
common ones that many users need.

I'm quite at loss what ordering comparisons on a hive would mean,
again because the high-level operational semantics
of a hive are unordered, so they don't make sense as something that
should be provided via a spaceship, either.

Summa summarum: just drop the comparison operators.

Received on 2022-03-15 14:41:57