rjmccall at apple.com
Thu Apr 14 15:09:56 CDT 2016
> On Apr 14, 2016, at 12:01 PM, Milos Rankovic via swift-evolution <swift-evolution at swift.org> wrote:
> Hi Andrey and Laurent,
>> On 14 Apr 2016, at 19:23, Andrey Tarantsov <andrey at tarantsov.com <mailto:andrey at tarantsov.com>> wrote:
>> Can you please give us a few real-world examples where initializing a nontrivial tree-like data structure in code would be useful?
>> It's an honest question — I have never felt the need in my life, and I always preferred to move the data into something like a bundled json or CSV, rather than providing it in code.
> I suppose we always prefer to move *all* data into databases or files with dedicated data formats, *including* arrays, strings, dictionaries, etc. Sure. But it would be rather underwhelming if you could not also just instantiate an array or a string from a literal.
>> On 14 Apr 2016, at 19:33, L Mihalkovic <laurent.mihalkovic at gmail.com <mailto:laurent.mihalkovic at gmail.com>> wrote:
>> I’d rather the language do NOT make it easy to have complex literals initializations
> I agree, except, something like `[1, ]` doesn’t immediately strike me by its complexity. Likewise, I find it a little deflating that I cannot express a piece of JSON in code. My example structures do allow you to write:
> let _: DictionaryTree<String, String> =
> "name": ◊"Johnny Appleseed",
> "address": [
> "streetAddress": ◊"21 2nd Street",
> "city": ◊"New York"
> … but I cannot get rid of that prefix operator without the additional literal-convertible protocols. Given the *simplicity* of these structures, it seems it should not be beyond Swift to represent them in code with ease and elegance. And to begin with, all we need are those couple of protocols.
I mean, you could just make your Tree type implement all the individual literal-convertible protocols.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution