Python Forum
Expanding on (+,*,%,/,//, etc...)= operator
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Expanding on (+,*,%,/,//, etc...)= operator
#1
I had an idea for how we write shorthand for a few binary functions (I'll use + as my example).

When we write
x += 2
, it really means
x = x + 2
, more generally since we can write addition as a binary relation, we can define it as
f
and then equivalently
x = f(x,2)
in that case, why not write the original statement as
x f= 2
?

On top of that for any function which isn't even binary, applying the same idea would yield the following shorthand for
x = g(x, a, b, c, ...)
to be
x g= a,b,c,...
What do you think?
Reply
#2
I think lines such as x = g(x, a, b, c) are not frequent enough to deserve such a special syntactic treatment. A language's syntax is a coherent set of carefully planned rules. Every odd idea must not be implemented.
cuppajoeman and Skaperen like this post
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020