On Thu, Jun 2, 2016 at 4:22 PM, Jeroen Demeyer <jdeme...@cage.ugent.be> wrote: > On 2016-06-02 15:52, Erik Bray wrote: >> 2. I know this is probably anathema to mathematicians, but couldn't >> "1/" be viewed as a two character unary operator meaning reciprocal? >> :) > > > Sort of, but keep in mind efficiency. Often, taking the reciprocal is more > efficient than coercion followed by a general division. > > Second, there might be structures where reciprocal makes sense but not > division in general. I cannot immediately think of something, but it might > exist.
As far as efficiency is concerned that's fair. But you could still use "1 / " as reciprocal without supporting division in any other sense. But then you have to deal with the usual mess of ensuring that the __rdiv__ method handles division for those objects. >> 3. Even if you managed to get / added as a unary operator in Python >> wouldn't you still have to support ~ for reciprocal for the >> foreseeable future if Sage is already using it that way? > > > I'm sure that every other problem is trivial compared to getting Python > accept this :-) > Anyway, you can use the preparser plus deprecations to deal with that. > >> 4. Before going through the hazard that is adding new syntax to >> Python, would this be easier to implement just in the Sage interpreter >> as syntactic sugar instead? > > > No, because we really want this in Python code, not just the Sage command > line. Currently, ~x is used a lot in the Sage library. A lot of really neat things can be done with codecs in Python. I think Sage should use more of that. -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.