Re: [swift-evolution] [Pitch] Add Null struct to Foundation

2016-06-27 Thread Michael Peternell via swift-evolution
well, JSONSerialization uses NSNull() as the null value currently. I think this is right, because a JSON null is conceptually a different thing than `nil as Any?` - Representing null as "not any value" a.k.a. `nil as Any?` would be a pun in my opinion. -Michael > Am 27.06.2016 um 08:32

Re: [swift-evolution] [Pitch] Add Null struct to Foundation

2016-06-27 Thread Jean-Daniel Dupas via swift-evolution
> Le 27 juin 2016 à 00:00, Michael Peternell via swift-evolution > a écrit : > >> >> Am 26.06.2016 um 23:03 schrieb Jean-Daniel Dupas via swift-evolution >> : >> >> Optional are definitely the best way to represent null when parsing

Re: [swift-evolution] [Pitch] Add Null struct to Foundation

2016-06-26 Thread Saagar Jha via swift-evolution
Any? or AnyObject?; have your dictionary be something like [String: AnyObject?]. On Sun, Jun 26, 2016 at 3:00 PM Michael Peternell via swift-evolution < swift-evolution@swift.org> wrote: > > > Am 26.06.2016 um 23:03 schrieb Jean-Daniel Dupas via swift-evolution < > swift-evolution@swift.org>: >

Re: [swift-evolution] [Pitch] Add Null struct to Foundation

2016-06-26 Thread Michael Peternell via swift-evolution
> Am 26.06.2016 um 23:03 schrieb Jean-Daniel Dupas via swift-evolution > : > > Optional are definitely the best way to represent null when parsing JSON. > >> Le 26 juin 2016 à 22:35, Michael Peternell via swift-evolution >> a écrit : >>

Re: [swift-evolution] [Pitch] Add Null struct to Foundation

2016-06-26 Thread Jean-Daniel Dupas via swift-evolution
Optional are definitely the best way to represent null when parsing JSON. > Le 26 juin 2016 à 22:35, Michael Peternell via swift-evolution > a écrit : > > Just one question: If I have functions > > json_encode(j: JSON) -> String > and > json_decode(j: String) ->

Re: [swift-evolution] [Pitch] Add Null struct to Foundation

2016-06-26 Thread Michael Peternell via swift-evolution
Just one question: If I have functions json_encode(j: JSON) -> String and json_decode(j: String) -> JSON throws what should be the type of JSON? What should '{"a":2,"b":null}' decode to? What should the type of the JSON null value be in Swift? I think String and String? and String??? are wrong

Re: [swift-evolution] [Pitch] Add Null struct to Foundation

2016-06-26 Thread David Rönnqvist via swift-evolution
I'm not convinced that Swift needs more than on way of representing the lack of a value. As far as I've understood (and remember), NSNull main reason to exist is that it's an actual object and won't for example terminate array literals. From what I've observed of people who are new to

Re: [swift-evolution] [Pitch] Add Null struct to Foundation

2016-06-22 Thread Alsey Miller via swift-evolution
Please see https://github.com/PureSwift/SwiftFoundation/blob/develop/Sources/SwiftFoundation/Null.swift https://github.com/PureSwift/SwiftFoundation/blob/develop/Sources/SwiftFoundation/JSON.swift

Re: [swift-evolution] [Pitch] Add Null struct to Foundation

2016-06-22 Thread David Waite via swift-evolution
> On Jun 22, 2016, at 10:14 PM, Alsey Miller via swift-evolution > wrote: > > Add a struct Null to the Swift 3.0 Foundation value types. As a struct, Null > is more performant (no ARC or memory allocation) than NSNull, and will be > needed for Swift JSON decoders

[swift-evolution] [Pitch] Add Null struct to Foundation

2016-06-22 Thread Alsey Miller via swift-evolution
Add a struct Null to the Swift 3.0 Foundation value types. As a struct, Null is more performant (no ARC or memory allocation) than NSNull, and will be needed for Swift JSON decoders and libraries that want to use struct value types, and be free from classes for their model layer.