aleck,
@aleck@mastodon.social avatar

This is an important thread, I recommend to read all of it.

From: @krzyzanowskim
https://mastodon.social/@krzyzanowskim/112209272364512363

mattiem,
@mattiem@mastodon.social avatar

@aleck I think something that is missing here is the problem isn’t the delegate pattern at all. The issue is it’s hard to make classes Sendable. And the reason it’s hard is because it is almost never the right solution to isolation issues.

But the alternative, find out why you want this to be Sendable in the first place and change that might require rethinking how you are using concurrency.

krzyzanowskim,
@krzyzanowskim@mastodon.social avatar

@mattiem @aleck Matt, the alternative is unforcable if the requirement comes from the third-party dependency (sendable protocol). So what happened is I updated dependency, now it requires Sendable in that protocol and I should to adapt. I don't even use it for concurrency myself.

so, how do we suppose to implement delegate now?

mattiem,
@mattiem@mastodon.social avatar

@krzyzanowskim @aleck Ahh you are trying to conform to this protocol? I didn’t see that in the example!

ctietze,
@ctietze@mastodon.social avatar

@krzyzanowskim @mattiem @aleck Dang that sounds hard.

WDYT: Maybe the upstream protocol should be changed to not be Sendable? Could have been adopted mistankingly, so maybe it's reversible.

I just hope it's not 1st party API 😬

mattiem,
@mattiem@mastodon.social avatar

@ctietze @krzyzanowskim @aleck this is now a completely different problem. I don't think making a protocol Sendable is a good idea because it is extremely restrictive. But, actor and global-actor-isolated types are Sendable. So, if all the protocol's methods are async, then that's an option.

If not, this is an API that was easy to make, but will be extremely hard/impossible to use. And that is surprisingly easy to do with protocols + concurrency.

krzyzanowskim,
@krzyzanowskim@mastodon.social avatar

deleted_by_author

  • Loading...
  • mattiem,
    @mattiem@mastodon.social avatar

    @krzyzanowskim @ctietze @aleck Apple has used concurrency in unusual/wrong ways in many places. Does not surprise me at all. Which API is it?

    hal,

    @krzyzanowskim yeah your example doesn’t make that clear at all. Just because FooDelegate protocol is Sendable, doesn’t mean that your Foo class needs to be Sendable. In your example you could just remove Sendable from Foo

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • mdbf
  • ngwrru68w68
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • osvaldo12
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • InstantRegret
  • tacticalgear
  • anitta
  • ethstaker
  • modclub
  • cisconetworking
  • tester
  • GTA5RPClips
  • cubers
  • everett
  • megavids
  • provamag3
  • normalnudes
  • Leos
  • JUstTest
  • lostlight
  • All magazines