Skip to content

Better description of Operators #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
max-carroll opened this issue Jul 22, 2020 · 3 comments
Open

Better description of Operators #71

max-carroll opened this issue Jul 22, 2020 · 3 comments

Comments

@max-carroll
Copy link

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?

@thbwd thbwd transferred this issue from emojicode/emojicode Jul 23, 2020
@thbwd
Copy link
Member

thbwd commented Jul 23, 2020

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

@joeskeen
Copy link
Contributor

joeskeen commented Nov 10, 2021

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

@thbwd
Copy link
Member

thbwd commented Nov 11, 2021

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants