On Saturday, August 15, 2020 at 11:38:17 AM UTC-7, Jonathan Kliem wrote: > > Could we have meaningful error messages somehow for coercion failure? > [...]
> TypeError: unsupported operand parent(s) for +: 'Number Field in sqrt5 > with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?' and > 'Algebraic > Real Field' > [...] > Maybe a user could get some hint that number fields can be specified with > fixed embedding and that conversion works either way. > I think the message is very meaningful: it exactly describes what goes wrong. The fact that the message follows a fixed pattern is actually helpful in recognizing the problem for people with some experience with sage. It may be the case that there is room for generating helpful suggestions for inexperienced users. Basically, something that matches traceback/imput patterns to FAQ items. WIth the current state of machine learning and language processing, this might actually be something that can be made to perform to some satisfactory degree, but it would take into account much more than just the place where the error arises. Alternatively, we may be able to get a similar result by writing a really good FAQ and let Google index it, so that we get to borrow their language processing. There are places in sage where managing complexity of the error message is worthwhile, and I think the coercion system is one: there are places where sage tries several possibilities and catches the errors. Sage even has specific "lazy" error messages for that, so that the message doesn't get expanded unless the string is actually called for. If I'm not mistaken, this particular message is an example of that. These parent representations can have a real cost to them, so that you don't want to risk generating them in a time-critical part of the code (where the string is thrown away anyway). So, I suspect that there's a real cost to making coercion error messages more expensive to generate. That gives another argument against doing so. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/3e232e94-ce4c-4626-a62b-88f977c8ecf2o%40googlegroups.com.