emojicode.github.io
emojicode.github.io copied to clipboard
Better description of Operators
In the documentation there is a list of operators
binary-operator ⟶ ➕ | ➖ | ➗ | ✖️ | 👐 | 🤝 | ◀️ | ▶️ | ⭕️ | 💢 | binary-operator ⟶ ❌ | 👈 | 👉 | 🚮 | 🙌 | 😜 | ◀️ 🙌 | ▶️ 🙌
However which one's which, they vary in how obvious their operation is,
Could we have like a legend for at least And / Or / Equals / Doesn't Equal?
Agreed. Labeling them would certainly make this chapter easier to understand (although you can overload them arbitrarily).
I had this difficulty as well; the "Aha!" moment for me was when I found that most of those operators are defined in the data-type specific s
library docs page. Perhaps adding verbiage and links to the package reference would help people better understand?
I also see value in having a legend/table that defines the intent of the functionality for each operator. Something like this (which took me a lot of time trying to grep through the docs to understand and put together, please forgive me if there are mistakes):
Operator Support
Operator | Description | 🔡 | 🔢 | 💯 | 👌 |
---|---|---|---|---|---|
➕ | Addition | ❌ | ✔ | ✔ | ❌ |
➖ | Subtraction | ❌ | ✔ | ✔ | ❌ |
➗ | Division | ❌ | ✔ | ✔ | ❌ |
✖️ | Multiplication | ❌ | ✔ | ✔ | ❌ |
👐 | Logical OR | ❌ | ❌ | ❌ | ✔ |
🤝 | Logical AND | ❌ | ❌ | ❌ | ✔ |
◀️ | Less Than | ❌ | ✔ | ✔ | ❌ |
▶ | Greater Than | ❌ | ✔ | ✔ | ❌ |
⭕️ | Bitwise AND | ❌ | ✔ | ❌ | ❌ |
💢 | Bitwise OR | ❌ | ✔ | ❌ | ❌ |
❌ | XOR | ❌ | ✔ | ❌ | ❌ |
👈 | Shift bits Left | ❌ | ✔ | ❌ | ❌ |
👉 | Shift bits Right | ❌ | ✔ | ❌ | ❌ |
🚮 | Modulus | ❌ | ✔ | ✔ | ❌ |
🙌 | Equality (Value) | ✔ | ✔ | ✔ | ✔ |
😜 | Equality (Reference) | ❌ | ❌ | ❌ | ❌ |
◀️🙌 | Less Than or Equal To | ❌ | ✔ | ✔ | ❌ |
▶️🙌 | Greater Than or Equal To | ❌ | ✔ | ✔ | ❌ |
❎❗️ | NOT | ❌ | ❌ | ❌ | ✔ |
🔡❗️ | Convert to string | ✔ | ✔ | ✔ | ❌ |
🔢❗️ | Convert to integer | ✔ | ❌ | ✔ | ❌ |
💯❗️ | Convert to real number | ✔ | ✔ | ❌ | ❌ |
I like the table! Feel free to open a pull request to add it to the operators' page. Three things to keep in mind, though:
- The last four entries of your table are method calls and thus not related to operators.
- Your table only shows value types, for which 😜 can't work a priori. I'm not sure if it makes sense to include it.
- Every type is free to implement these operators (except for 👐, 🤝 and 😜) as it sees fit, just as C++ or Ruby give
<<
meanings beyond bit shifting like printing or appending to an array, respectively. We should always differentiate between language features and functionality provided by a package (even if it's the s package).