I'm not a design patterns expert, but does using two separate APIs in close proximity actually count as composition? I've never heard of, say, drawing APIs which require context.allocate(); context.fill()
to fill an already set color as being a composition of allocation and filling.
Mainly I'm worried that the feature, as pitched, is easy to get wrong since it requires both sets of targets to be separate. It also relies on two attributes to get one feature.
But you're right that the alternative @available
syntax isn't great, especially requiring separate declarations for each platform. I do wonder if there's room for something like @available(macOS (12 backDeployedTo: 10.15), iOS (15, backDeployedTo: 13), *)
. Verbose, but allows us to immediately align both stable and back deployed targets, and could easily be replaced with year macros when they're available. @available(apple (2021, backDeployedTo: 2019), *)
.
I'm not really satisfied with that version either, but perhaps others have ideas.