I like the query syntax too. If we really need it, we can add syntactic sugar later.
Thank you for working on this! Vinzent On Feb 21, 11:50 am, Fabian Seoane <[email protected]> wrote: > Hi all. As part of my work in the assumptions branch[1], I'm faced to the > problem of finding a new syntax for the expr.is_* property. > > It seems that last time we talked about it, we used the following syntax for > querying an element (although we did not discuss it) > > IsPositive(x) > IsElement(x) > etc. > > This is ok, but I find it cumbersome to have so many methods (at least one > for each assumption we support). Alternatively, my implementation > proposes another solution based on the query method. You can see it's > implementation here [2]. Examples would look like: > > query(x, 'positive') > query(x, 'real') > > It works the following way: > Each query key ('positive', 'real') defines a QueryHandler that is > responsible for handling the resolution of the current query. Then > query_dict maps each assumption > to it's handler. Of course we could define shortcuts: > > def IsPositive(x): > return query(x, 'positive') > > The nice thing here is extensibility: If any third-party module would like > to add new query keys (query(x, 'my_key')), just append the appropriate > handler to query_dict (all this is better understood looking at [2]). > > Of course, Is* syntax can also be made extensible by subclassing, so it all > comes at the end to a matter of consistency. > > Any comments? Which syntax do you prefer ? > > [1] You can check it out fromhttp://fseoane.net/git/sympy.git, branch > assumptions > [2]http://fseoane.net/cgi-bin/gitweb.cgi?p=sympy.git;a=blob;f=sympy/core... > -- > Fabian,http://fseoane.net/blog/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
