[swift-evolution] [Proposal] Revamp the playground quicklook APIs
Connor Wakamo
cwakamo at apple.com
Wed Jan 10 16:11:05 CST 2018
> On Jan 10, 2018, at 1:58 AM, Ian Partridge <ian at poncho.org.uk> wrote:
>
> On 9 January 2018 at 23:19, Connor Wakamo via swift-evolution
> <swift-evolution at swift.org> wrote:
>> To that end, I am proposing the following:
>>
>> - Introduce a new protocol, CustomPlaygroundRepresentable, in the
>> PlaygroundSupport library in Swift 4.1:
>>
>> protocol CustomPlaygroundRepresentable {
>> /// Returns an alternate object or value which should stand in for the
>> receiver in playground logging, or nil if the receiver’s default
>> representation is preferred.
>> var playgroundRepresentation: Any? { get }
>> }
>
> I was always surprised that "Playground" was a word/concept that the
> Standard Library used, as playgrounds are an Xcode feature and iOS app
> which are not part of the Swift open source project.
Agreed — which is why this proposal moves it into the playground-specific PlaygroundSupport library instead of leaving it in the standard library.
> I think it might be better if names for these could be found which
> reflect the functionality they provide, in a non "playground" specific
> way. After all, AFAIK it would be possible for non-"playground" uses
> of CustomPlaygroundRepresentable.
As mentioned in another email, I’m open to naming suggestions. That being said, in the same way that there’s `CustomStringConvertible` and `CustomDebugStringConvertible`, if we come up with a generic name for this, I think I’d still probably want a playground-specific version of it that lives in the PlaygroundSupport library so that code can customize its behavior to be appropriate for different environments/audiences.
Connor
More information about the swift-evolution
mailing list