Bikeshed: A consise verb for the `?` operator


#81

I am aware that when framing ? as a monadic/applicative construct, the mechanism implementing then is bind.

What I don’t understand is how you agree that, semantically,? operates like a conjunction (“then maybe”), but still prefer a verb. The verbs, in your illustration above, are bar(), baz(), etc.

This is doubly hard to reconcile with your argument that try/? is a “happy path” construct. Conjunctions pair well with the happy path, verbs do not.

Compare:

foo.bar, then maybe baz, then maybe biz, then maybe buz

or

foo.bar, therefore baz, therefore biz, therefore buz

with your preferred nomenclature:

foo.bar rethrow, baz rethrow, biz rethrow, buz.

foo.bar propagate, baz propagate, biz propagate, buz.

foo.bar bubble, baz bubble, biz bubble, buz.

I agree that no single word will capture the full extent of the operation, but the above demonstration shows that a conjunction offers more clarity than a verb. The conjunction captures the conditionality of the construct, a quality unmatched by rethrow, propagate, or bubble.


#82

I have trouble reading the example code with conjunctions like therefore on the opposite side of the call site from the operator in question (pun intended).

foo.bar()?

foo, therefore bar

The ? operator is clearly in a suffix position, which implies the above reading is in some ways “backwards”. It’s like the dollar sign, which has always been something I’ve hated.

$100

One hundred dollars

Compare with temperatures:

21°C is 69.8°F

Twenty-one degrees Celsius is sixty-nine point eight degrees Fahrenheit

The point I’m trying to make is that dollars and degrees are neither conjunctions nor verbs. They are nouns. Guess what else is a noun? bubble


#83

I think bubble does well on conditionality, since in a technical context it makes me think of bubble sort, where elements “bubble up” to the appropriate level, like errors do with ?.


#84

Whoops! That’s an error on my part. I only meant to add “therefore” where the ?'s are in the original. I updated my examples. Thank you for pointing that out!

I think of it in similar terms, though instead of a bubble sort it’s events bubbling up the DOM. I certainly like it the most of the verbs mentioned, but it made me feel uneasy and I wasn’t aware of why until I read the exception paper I linked above. I think of ? as the “connective tissue” between fallible actions, much like a conjunction.


#85

I tend not to mentally pronounce ?, but instead I read the expression it’s attached to with question intonation. So I might mentaly read try_thing(foo)? as “try_thing of foo?”, or mutex.lock()? as “mutex dot lock?” (kinda hard to express over text =P). Curious to hear if other folks do this.

Not that it helps give ? a name; personally, I when I read ? not attached to an expression I just mentally say “q”.


#86

I also think about the DOM when I hear “bubble”. In web programming it means that an event travels up the tree. There’s nothing conditional about it. It just travels upwards. There’s only ever one parent element and it travels until it either reaches the root or the propagation is manually stopped.


Let’s focus on counter arguments. I’d like to hear some for “check”. Various people said they like it, but the only counter argument that was mentioned so far was:

  • Why does it seem generic?
  • The boolean feeling comes probably form “checkboxes” or QA checks. However, those kind of associations are exactly what we what

For “maybe” there was:

I agree with both statements.


#87

I’d probably call it the question-mark operator because that name corresponds directly to its appearance. It would probably also be the most obvious name to search for when trying to learn Rust.

I do like the word check as the verb for this operator, as in: “verify as to correctness”, and for the general connotation of “interrupting the current motion”.

When reading Rust code the ? can also be read as the interjection “check!”, meaning “all right!”. This highlights the happy path while giving a small pause.


#88

“check” is the best name for the concept I’ve heard yet, whereas, “question mark operator” is the best name I’ve heard for naming the operator itself. I nominate:

  • Concept: Check
  • Name of Operator: Question Mark Operator

Sounds good to me.


#89

What about the “gate” operator? The concept of having a gate/door that you can pass or be rejected from seems appropriate. As if ? was a bouncer at the door for the “happy path”. Maybe “bouncer” operator could work as well.

EDIT: Also sounds like a purgatory where the distinction between good and bad is made :stuck_out_tongue:

Purge: In history, religion and political science, a purge is a removal of people who are considered undesirable by those in power from a government, another organization, their team owners, or society as a whole.


#90

This reminds me of the 2nd definition of limbo:

an uncertain period of awaiting a decision or resolution; an intermediate state or condition.

Though, when I think of a “limbo operator”, I think of the competitive kind.