> On 5 Jul 2023, at 21:07, Chris Angelico <ros...@gmail.com> wrote:
> 
> On Thu, 6 Jul 2023 at 04:02, Dom Grigonis <dom.grigo...@gmail.com> wrote:
>> What I would alternatively propose is to introduce a couple of (meaningless 
>> operators), so that library developers can make use of them as they wish. 
>> What characters aren't used? “$, ?, `” (or are they?).
>> 
> 
> What should their precedences be? Operators have to be given that, at
> least. Unfortunately, whatever precedence you choose, it's going to be
> awkwardly wrong for at least some potential use-cases.
Lowest precedence?

a + b + c ?op? a / b / c
a + b + (c ?op? a) / b / c

As this in theory is the highest level operator, given it would mostly be used 
in framework level packages, it’s precedence naturally begs for the lowest 
status.

But yes, then this would limit the operator to certain use cases. E.g. it 
wouldn’t be suitable to solve the problem of OP.

> That said, though, there are some pretty cool packages out there that
> create arbitrary operators. Some of them take advantage of multiple
> operators to allow multiple effective precedences. Consider for
> example:
> https://pypi.org/project/infix/
Infix operator is where my though process began in the first place - see the 
e-mail. My proposal is exactly to have a free operator to be used in packages 
such as the one you pointed to. Ok, so Infix works in the way that operands can 
not recognise object in between operators, so that it falls to `dunders` of the 
object between operators. Although this works, there would be more flexibility 
if both the operands and operator class had `free` operator implementation 
space. Some new patterns might arise.

It would be cleaner approach, currently `Infix` feels a bit hacky to me due to 
reusing of operators, which have another purpose.


> ChrisA
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/YQDJ5UMH23FYL5FVFNBLWPOROD5ZZQOG/
> Code of Conduct: http://python.org/psf/codeofconduct/

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/RVAKUXJ53QUBWFBGOSWTHP47HE3C4GCR/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to