Re: [Swift] best way to support 'keyword' args, symbolic values, show values as literals?
Re: [Swift] best way to support 'keyword' args, symbolic values, show values as literals?
- Subject: Re: [Swift] best way to support 'keyword' args, symbolic values, show values as literals?
- From: Quincey Morris <email@hidden>
- Date: Mon, 15 Jun 2015 17:39:38 +0000
On Jun 15, 2015, at 10:17 , has <email@hidden> wrote:
>
> the goal is to enable a user to print an object specifier and be able to copy-and-paste that straight into another script - i.e. `-description` should always return a string that represents valid Swift code
I dunno about #1 or #2, but for #3 look into the “Custom…” family of protocols, especially ‘CustomStringConvertible’, which is the one that defines ‘description’ and ‘debugDescription’ as having more-or-less their Obj-C meanings. IIRC, CustomStringConvertible is also the one that allows your custom type to participate in string interpolation: “\(variableOfYourType)”, which would connect you with what I assume you mean by “printing".
The standard protocols are all documented in the Swift Standard Library document for Swift 2. It’s worth browsing the list to see if there’s other stuff that might be helpful. Any of the “…Convertible” protocols might open up possibilities for streamlining your invocation syntaxes.
HTH
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden