> On Apr 14, 2016, at 12:01 PM, Milos Rankovic via swift-evolution
> <[email protected]> wrote:
> Hi Andrey and Laurent,
>
>> On 14 Apr 2016, at 19:23, Andrey Tarantsov <[email protected]
>> <mailto:[email protected]>> 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 <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> I’d rather the language do NOT make it easy to have complex literals
>> initializations
>
>
> I agree, except, something like `[1, [2]]` 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.
John.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution