chanced / jsonptr

JSON Pointer (RFC 6901) implementation for Rust
Apache License 2.0
44 stars 4 forks source link

`Pointer::union` is misleadingly named #28

Closed asmello closed 2 months ago

asmello commented 5 months ago

When used as an operator, the term union conventionally alludes to the set theoretical definition. From Wikipedia:

In set theory, the union (denoted by ∪) of a collection of sets is the set of all elements in the collection.

In more concrete terms, when given two sets of items, their union is the set of all elements from either set. So when the term is applied to a JSON Pointer, one might expect that the result would somehow contain the tokens from both inputs, when in reality it only contains their shared part. This more accurately represents an intersection operation, which is the opposite of a union, so the naming is surprising and easily leads to confusion.

The most accurate term would be longest common prefix, as this is the algorithm that the method implements. To keep it short, the abbreviation lcp is often used. I think intersection would probably also be fine, though.

chanced commented 5 months ago

Ugh, thank you. That one is especially embarrassing 🤦🏻‍♂️.

I'll deprecate it and rename for 0.4.

asmello commented 5 months ago

Awesome! I think you meant the rename for 0.5 though? We are at 0.4.x releases.

chanced commented 5 months ago

I meant I’ll rename it but alias the existing, improperly named, fn to the new and deprecate it.

On Tue, Mar 19, 2024 at 6:52 PM André Mello @.***> wrote:

Awesome! I think you meant the rename for 0.5 though? We are at 0.4.x releases.

— Reply to this email directly, view it on GitHub https://github.com/chanced/jsonptr/issues/28#issuecomment-2008296933, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIGFZENJSYNNZ6U3CZUDV3YZC6ULAVCNFSM6AAAAABE6NR66OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBYGI4TMOJTGM . You are receiving this because you commented.Message ID: @.***>