On Sun, Feb 2, 2020, at 11:41, MRAB wrote: > On 2020-02-02 15:00, Karl Ramm wrote: > > We have all shared in the observation that all but the most carefully > > considered operator overloading tends to reduce code readability. There > > also many programmers that feel that they need it to make there code terse > > (or perhaps shiny) enough. > > > > I propose adding ! and $ as (normally unimplemented) binary operators and ? > > as a unary operator so as to explicitly to give people the rope they want > > but clearly tagged "here there be shenanigans". > > > In the past there have been suggestions to add None-coalescing > operators > such as "?." and "??", comparable to the null-coalescing operators of > C#, so I'm -1 on just adding "!", "$" and "?" without a solid use-case, > in case we find a better use for them later in the future.
Before the nameof discussion got shut down, I was going to propose $nameof as a way to avoid collision with a function called "nameof", and I still think it's viable as a general way to make an open-ended set of keywords that don't collide with identifiers [frozenset literals?]... so I'm also -1 on cutting down the number of reserved ASCII characters without a very good concrete use case. If we are going to have a general binary operator mechanism, maybe it should be something more haskell-like, with an open-ended set of binary operator names [`identifier` as haskell, perhaps? and/or maybe the unicode math ops section, with stuff like circled plus] and a way to define precedence before the point of use for the parser. Perhaps it would also be useful to provide a utility function for performing the __op__/__rop__/NotImplemented/most-derived-class binary operator execution rules on an arbitrary pair of method names, without *any* syntactical support [in order to, say, allow evaluation of custom ASTs for non-python languages on python objects] _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/GISGMZLBZ3FRT77QWJ3EXUGJTGJC2MEG/ Code of Conduct: http://python.org/psf/codeofconduct/
