(Yes, this is not easy.   If you were writing this for your own use, you wouldn't bother with all of this.  But functions in `Base` need to be as generic and high-performance as is practical.)