Closed mentalisttraceur closed 2 years ago
So far, every time I think about this, I eventually come back to:
It should exist, and it should be a subclass of EUI48
.
But this is a shaky position in my mind... there are enough compelling reasons for it to tentatively settle on it, but there are enough compelling reasons against it to occasionally jostle me into doubt.
Some prior discussion of this in #3 .
Couple examples of real-world code which would break on an upgrade to version 2.* if MAC
was removed:
The reasons I can remember for subclassing:
Nicer errors - you call MAC(foo)
and get "could not parse as MAC" rather than "could not parse as EUI48".
Some uses of EUI-48 are not as addresses, not for "media access control" - so every MAC address is an EUI-48, but not every EUI-48 is a MAC address. (But this is a purely conceptual distinction - intent or purpose as interpreted or asserted by minds. It is good to express such "business logic" in the type system if it matters.)
Reasons I can remember for having MAC
at all:
Realistically, what's the consequences in either direction?
Remove MAC
entirely:
Make MAC
an alias to EUI48
:
repr
of MAC
instances need to be changed;isinstance(..., MAC)
because it's intuitive rather than because of a conscious desire to distinguish from the EUI48
class, so this could be fixing more things than it breaks;MAC
the same class as EUI48
will have; andKeep MAC
a subclass of EUI-48
:
isinstance(..., MAC)
check even though isinstance(..., EUI48)
was more appropriate.So I think I the verdict is aliasing MAC = EUI48
in version 2.0.0.
Basically I seem to have convinced myself that the reasons for distinguishing MACs as a subset of all EUI-48s out there are not strong enough to accept the likely inevitable consequence of doing so if there are enough users.
In fact I see a more general principle in favor of not providing distinct subclasses for MAC vs EUI-48 in general in this library.
Languages and libraries should generally be in the business of providing functionality, not inflicting non-functional or irrelevant or incidental semantics and taxonomy.
Maybe there's exceptions to that, but I think that's pretty generally true.
Basically, what I'm saying is that the distinction between EUI-48 and MAC is like the distinction between "unsigned integer" and "number of cows": it is relevant in some code and that code should make the distinction as appropriate, but something that provides the former should not impose distinguishing the latter onto its users.
Should
macaddress.MAC
be provided by this library (it currently is)?If so, should it be
macaddress.EUI48
(like it is now),macaddress.EUI48
,