unify operator overloading
See original GitHub issuea syntax like:
operator def (a: Int) + (b: Int) -> Int:
...
could allow us to unify unary and binary operators. We might not want many operators which have not been popular in most programming languages. That said, it is ugly to have some exceptions to rules and it makes things harder to learn.
Issue Analytics
- State:
- Created 6 years ago
- Comments:23 (15 by maintainers)
Top Results From Across the Web
Chapter 14 Overloaded Operators
Chapter 14 Overloaded Operators. A Modelica operator record can define the behavior for operations such as constructing, adding, multiplying etc.
Read more >Rules for Overloading and Overload Operators
There are ten rules for overloading and overload operators in the C++ core guidelines. Many of them are quite obvious, but your software...
Read more >Operator Overloading - C++ Fundamentals for Professionals
We can overload the assignment operator by implementing it as a copy or move assignment operator. It has to be implemented in a...
Read more >Unification (computer science)
In logic and computer science, unification is an algorithmic process of solving equations between symbolic expressions. Depending on which expressions (also ...
Read more >Chapter 10: Operator Overloading
When used correctly, operator overloading can lead to intuitive, template-friendly code that elegantly performs complex operations behind the scenes. However,.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
so my new proposal is that
operator ++
is exactly likeconcat
for instance. It can appear anywhere a binding name can:etc…
So,
operator
is a key word that allows us using operator names as binds.Then next part is that an operator without that prefix
f +
is parsed asApply(Operator("+"), f)
.The last part is that we will limit operators to avoid
:
_
,
@
(
)
and.
so we don’t have any ambiguity with other existing symbols.I think with #192 it should be pretty easy to implement this (although doing that refactor was a brutal several hours…)
-x could just be 0-x or neg(x) or x.neg
Simplicity and consistency are major goals here. That will inevitably leave some verbose corners.