emojicode.github.io icon indicating copy to clipboard operation
emojicode.github.io copied to clipboard

Better description of Operators

Open max-carroll opened this issue 4 years ago • 3 comments

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?

max-carroll avatar Jul 22 '20 18:07 max-carroll

Agreed. Labeling them would certainly make this chapter easier to understand (although you can overload them arbitrarily).

thbwd avatar Jul 23 '20 13:07 thbwd

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

joeskeen avatar Nov 10 '21 21:11 joeskeen

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:

  1. The last four entries of your table are method calls and thus not related to operators.
  2. Your table only shows value types, for which 😜 can't work a priori. I'm not sure if it makes sense to include it.
  3. 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).

thbwd avatar Nov 11 '21 08:11 thbwd