| 12 Oct 2025 |
raitobezarius | i will take a look on Monday | 15:42:14 |
QuadRadical (Ping) | ah no worries, have a nice weekend | 15:42:50 |
Sofie 🏳️⚧️ (she/her) | What is the shortest syntax to do something like
if condition then "arf arf :3" else "meowww :3"
| 17:03:11 |
Sofie 🏳️⚧️ (she/her) | that syntax for me is kinda bulky | 17:03:34 |
n3tcat | lix ternary operator when | 17:07:52 |
vczf | I would like a ternary operator in nix | 17:08:04 |
bandithedoge | exactly this | 17:12:02 |
aloisw | In reply to @stephen:crabsin.space lix ternary operator when if then else is the ternary operator. | 17:31:52 |
n3tcat | "good ternary operator when" then | 17:38:47 |
Charles | What makes a ternary operator good? | 17:42:28 |
Charles | Forgettable syntax like in C? | 17:42:51 |
vczf | foo ? a : b operator chains well in dart/flutter for complex widget trees. Nix attrsets have a similar structure, so I think it would be a good fit | 17:42:58 |
n3tcat | how is it any more forgettable than % for modulus or * for multiplication or anything else? | 17:43:41 |
n3tcat | idk that feels like a nitpick to me | 17:43:45 |
vczf | If dart had inline if-then-else it would be unreadable | 17:43:55 |
aftix |
- is used for literally everything, people who have never programmed can immediately see * is multiplication
| 17:44:39 |
n3tcat | that may be true, I'm not sure | 17:45:42 |
n3tcat | Is the same true for %? | 17:45:45 |
n3tcat | or || or &&? | 17:45:51 |
n3tcat | like was there a point to pick on * or did you legitimately not get the point I was making lol | 17:46:18 |
Charles | When I was learning programming I struggled to remember the respective meaning of the second and third expression in C's ternary operator. Didn't have this problem with if. I think the only reason a language would want/need a dedicated ternary operator other than if it would be because the language forces those constructs to be statements (C) rather than allowing them to be expressions (Rust). If if is already useable as an expression, a ternary operator would be redundant | 17:48:11 |
n3tcat | I personally don't really have an issue with redundancy. Python tried to do the "only have 1 way to do things" philosophy and it was a disaster. No switch statements etc | 17:49:07 |
Charles | Redacted or Malformed Event | 17:49:16 |
n3tcat | lol | 17:49:24 |
Charles | On third thought it's actually fine | 17:49:42 |
Charles | * On third thought it's actually fine (re: redacted message) | 17:49:58 |
n3tcat | anyway I personally don't think it's a huge issue either way since if is an expression like you said, but yeah I would prefer the ? : syntax | 17:49:57 |
Charles | In reply to @stephen:crabsin.space I personally don't really have an issue with redundancy. Python tried to do the "only have 1 way to do things" philosophy and it was a disaster. No switch statements etc Python has match since 3.13 or something now | 17:50:27 |
n3tcat | Yeah I know | 17:50:41 |
n3tcat | but for a long time they didn't | 17:50:44 |