Promis...romise(3pm)

πŸ’– Promis...romise(3pm) πŸ’–

okay bestie, so this one lives in the 3pm section of the perl manual (user-contributed perl docs, we love to see it), and yes the title is literally spelled Promis...romise β€” the man page name got ate, we don't ask questions, we just vibe 🫢


✨ NAME ✨

Promise::XS::Promise β€” it's a promise object, that's the whole thing πŸŽ€


✨ SYNOPSIS ✨

ngl there's nothing here, it just points you at its bestie. Go see Promise::XS. πŸ’…


✨ DESCRIPTION ✨

So this right here? This is Promise::XS's actual promise object class β€” the real one, the main character, no understudies πŸ‘‘

It implements these methods:

  • then()
  • catch()
  • finally()

…and they do exactly what you'd expect them to do, because they behave as they normally do in promise implementations. No plot twists, no surprises, just promise behaviour as promised 😌

Bonus round: on top of those, all() and race() are also usable. Like this:

my $p3 = Promise::XS::Promise->all( $p1, $p2, .. );
my $p3 = Promise::XS::Promise->race( $p1, $p2, .. );

…or, keeping it cute and class-flexible:

my $p3 = ref($p1)->all( $p1, $p2, .. );
my $p3 = ref($p1)->race( $p1, $p2, .. );

…or even just calling it straight off the object itself:

my $p3 = $p1->all( $p1, $p2, .. );
my $p3 = $p1->race( $p1, $p2, .. );
🚨 bestie, look closely at those last two examples: $p1 shows up twice β€” once as the thing you're calling the method on, and again inside the argument list. That repetition is not a typo, it's just how it be. (The original man page literally parenthesises "Note the repetition of $p1 in these last examples!" so like, it's important, iykyk πŸ’€)

✨ NOTES ✨

Okay so, bad news for the "what if I made my own fancy subclass" girlies: subclassing this class won't work 😭

Why? Because all the methods named above always return instances of (exactly) this class β€” not your subclass, not your custom flavour, just plain Promise::XS::Promise. Periodt.

That might change eventually, but for now, this is what's what. πŸ€·β™€οΈ


and that's the whole page, bestie! no cap, no notes, we ate and left zero crumbs πŸ’…βœ¨ this was perl v5.42.3, dated 2026-08-22, signing off πŸ¦‹πŸ’–

πŸ“¦ where this page comes from