With a fresh kernel, run
Unprotect[Quantity];
Quantity[x_Around, "DimensionlessUnit"] := x;
gives
SetDelayed::write: Tag Quantity in x_Around is Protected.
But run it a second time, the warning disappears.
Why doesn't Unprotect work at the first time?
Quantity; Unprotect[Quantity]; ...; Protect[Quantity];. The first use of the symbol must be outside of theUnprotectinvocation. – Kuba hasn't forgotten Monica Jan 11 '24 at 18:58^=instead of:=is better at both expressing intent and maintaining evaluation speed. The latter IIRC adds a global rule, whereas the former adds an upvalue to Quantity and doesn't modify the global rule set. I'd thus suggestQuantity[x_Around,"DimensionlessUnit"]^:=x; UpValues[Around]vs.Quantity[x_Around,"DimensionlessUnit"]:=x; DownValues[Quantity]. – Kuba hasn't forgotten Monica Jan 11 '24 at 19:03