Re: [VOTE] True Async RFC 1.6

From: Date: Mon, 24 Nov 2025 19:11:27 +0000
Subject: Re: [VOTE] True Async RFC 1.6
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  Groups: php.internals 
Request: Send a blank email to internals+get-129443@lists.php.net to get a copy of this message
Hi Rowan, > On Nov 25, 2025, at 02:57, Rowan Tommins [IMSoP] <imsop.php@rwec.co.uk> wrote: > > On 24/11/2025 13:20, Edmond Dantes wrote: >> This makes it impossible to accidentally shoot yourself in the foot. A >> developer can still do something silly by explicitly passing objects >> between coroutines, but now they are doing it consciously. > > > Again, you completely avoided my question, and went back to ambiguous statements about "a > developer". > > To stick to my personas: > > - SDK Susie does not know what implementation of LoggerInterface will be passed to her library. > How does she know if it is safe to use in her asynchronous code? > > - Legacy Les is using a LoggerInterface implementation written years ago. How does he know > whether it is acceptable for use with Susie's library? I would argue that LoggerInterface only accounts for a synchronous implementation. It is impossible for an asynchronous implementation to meet the requirements of the interface. An AsyncLoggerInterface would be required. However, any synchronous implementation that otherwise matches the requirements would implicitly match. (Any non-asynchronous function is effectively the same as an asynchronous function that has no suspension points.) Effectively, we would need something like: ``` interface LoggerInterface extends AsyncLoggerInterface { public function log($level, $message, array $context = []); ... } interface AsyncLogerInterface { public function log($level, $message, array $context = []) async; ... } ``` So if SDK Susie can certify that _their_ library will work correctly with an async logger, then they can indicate that by accepting an AsyncLoggerInterface (in place of, or separately from, a LoggerInterface). This is just an assertion that SDK Susie's library will work correctly in the face of an async logger. It's up to Async Alice and Beginner Bob to make sure they don't somehow footgun themselves with their own (new) async code. Legacy Les isn't passing in anything async, so as long as Susie's SDK doesn't violate its prior synchronous contract, Les shouldn't have anything to worry about. -John

« previous php.internals (#129443) next »