vctrs
vctrs copied to clipboard
ptype2 howto shouldn't advise `stop_incompatible_type()`
In https://vctrs.r-lib.org/reference/howto-faq-coercion.html
Should recommend vec_default_ptype2() instead.
Does this include stop_incompatible_cast()? Because I feel like being able to call that with custom details is pretty useful
https://github.com/DavisVaughan/int64/blob/0922226847a3eec5e4b5887490c8c82b8751a0e5/R/cast.R#L36-L41
yes I think so. The default method is where we implement all the special behaviour. Maybe we could pass details to stop_incompatible_cast()?
Why do I want the special behavior though? I'm confident that I want a cast/type error and was trying to directly throw a vctrs compatible one
Calling vec_default_cast() seems less readable because it seems to imply that there is a way that that cast could actually work
yes it can indeed actually work if someone overrides the method. For this to work, coercion methods should return the result of the default method instead of failing.
For future us:
someone overrides the method
is referring to utilizing a restart, like https://github.com/r-lib/vctrs/pull/1719