Perl has a really expressive set of conditional constructs that are used like ? (and which, TBH, I’d really appreciate in rust). They come in two flavours, but in general you use whichever expresses intent and “happy path” best.
- logical binary operators,
and / or, that are the same as the regular ones but bind with lowest precedence, and shortcut like normal (left-to-right)
- postfix
if and unless that evaluate the expression condition on the right first (unless x is obviously just if !x and can be used prefix or postfix)
They’re often used with looping early return (next) or exception (die and others) mechanisms, eg:
next unless $prerequisite;
open() or die "bozo!";
my $v = thing() or return;
do_thing() if $option;
evaluate() and perform();
Rust has a way to go before it gets this naturally expressive around working with Result, but I hope we can get there one day.
So, in the context of the current question, I tend to read ? like and (or “and then”) when it’s chained foo()?.bar() and like or die at the end of an expression. More specifically, I never read it as unless. For rust, it’s probably more like “or (return) error”.
As for how to pronounce it, lisp has a convention to name used as boolean predicate checks as foo-p, and they’re pronounced with a question-like inflection. I sometimes mentally read it that way, but it probably doesn’t work out-loud for all the podcasters out there…
For naming the operator, in the same way that ::<> is named turbofish but not really pronounced out loud like that when it happens, I like the “bubble” or “bubble chain” operator, just for whimsical value.
Now, if we’re really going for whimsy, given this thread, we should call it the shed operator. Like a crab unwraps itself by shedding an exoskeleton, and a call chain can shed errors.