[swift-users] File IO in Swift for Linux

2016-05-20 Thread John Myers via swift-users
I've just finished reading a very spirited debate on the merits of streaming versus reading in an entire file. I'm convinced that both are ideal depending on the situation. Thank you for the responses I received on my original post. I had tried previously on StackOverflow, having joined just for

Re: [swift-users] UnsafeMutablePointer in structs

2016-05-20 Thread Dan Stenmark via swift-users
No, you’ll have to wrap it in a class. That said, class references from a struct are frowned upon, as you may wind up sharing mutable state (which structs are meant to combat). What’re you trying to represent with the UnsafeMutablePointer? A connection handle? Dan > On May 20, 2016, at 12:5

[swift-users] UnsafeMutablePointer in structs

2016-05-20 Thread Adrian Zubarev via swift-users
Can I put an UnsafeMutablePointer inside a struct and destroy deallocate correctly without nesting a class which has `deinit`? I’m not sure how to check this. --  Adrian Zubarev Sent with Airmail ___ swift-users mailing list swift-users@swift.org https

Re: [swift-users] Mapping C semantics to Swift

2016-05-20 Thread Matthew Johnson via swift-users
> On May 20, 2016, at 12:54 PM, Joe Groff via swift-users > wrote: > > >> On May 20, 2016, at 7:33 AM, Ken Burgett via swift-users >> wrote: >> >> I have been told that the in-memory layout of a Swift struct is 'undefined', >> so the C style of aliasing an array over a struct and iterating

Re: [swift-users] Mapping C semantics to Swift

2016-05-20 Thread Joe Groff via swift-users
> On May 20, 2016, at 7:33 AM, Ken Burgett via swift-users > wrote: > > I have been told that the in-memory layout of a Swift struct is 'undefined', > so the C style of aliasing an array over a struct and iterating across the > struct is a definite no-no. Not surprising, since aliasing viola

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-20 Thread Jens Alfke via swift-users
> On May 20, 2016, at 9:44 AM, Jan Neumüller via swift-users > wrote: > > What advantage? Streaming IO is a pain in the . I never got what people > like at this stuff Well for one, it abstracts away the source of the data. It could be a file, a TCP socket, an HTTP body, the output of ano

Re: [swift-users] Mapping C semantics to Swift

2016-05-20 Thread Ken Burgett via swift-users
On 2016-05-20 08:55, Jens Alfke wrote: On May 20, 2016, at 7:33 AM, Ken Burgett via swift-users wrote: the required C struct morphs into a Swift class, with a member function 'as_C_byte_array' which answers an array of the required form. Internally, this function will shift and mask class attri

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-20 Thread Jan Neumüller via swift-users
> +1. There are many reasons to prefer streaming implementations. It is also > possible to write high-level APIs with relatively simple interfaces that use > streaming behind the scenes. The fact that this is not always done is not a > good argument against providing robust streaming APIs. I

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-20 Thread Matthew Johnson via swift-users
> On May 20, 2016, at 10:47 AM, Jens Alfke via swift-users > wrote: > > >> On May 20, 2016, at 1:16 AM, Quinn The Eskimo! via swift-users >> mailto:swift-users@swift.org>> wrote: >> >> One of the nice things about the file system is that it has reasonable >> performance and error characteri

Re: [swift-users] Mapping C semantics to Swift

2016-05-20 Thread Jens Alfke via swift-users
> On May 20, 2016, at 7:33 AM, Ken Burgett via swift-users > wrote: > > the required C struct morphs into a Swift class, with a member function > 'as_C_byte_array' which answers an array of the required form. Internally, > this function will shift and mask class attributes in order to build

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-20 Thread Jens Alfke via swift-users
> On May 20, 2016, at 1:16 AM, Quinn The Eskimo! via swift-users > wrote: > > One of the nice things about the file system is that it has reasonable > performance and error characteristics such that you /can/ deal with it > synchronously. Revel in that fact! That’s only really true at small

Re: [swift-users] Mapping C semantics to Swift

2016-05-20 Thread Ken Burgett via swift-users
I have been told that the in-memory layout of a Swift struct is 'undefined', so the C style of aliasing an array over a struct and iterating across the struct is a definite no-no. Not surprising, since aliasing violates all type-safe rules. So, if you have this situation, you must address it

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-20 Thread Gerard Iglesias via swift-users
Hello Interesting question From my point of view, I want to parse a huge file without loading it in memory... Maybe something worth the reading https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/TechniquesforReadingandWritingCustomFile

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-20 Thread Maury Markowitz via swift-users
> On May 20, 2016, at 4:16 AM, Quinn The Eskimo! via swift-users > wrote: > I disagree. One-shot file system APIs make sense for a lot of reasons: I do most of my programming in .Net, where streams are the primary IO system. Even simple tasks often require multiple objects and loops copying da

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-20 Thread Quinn "The Eskimo!" via swift-users
On 19 May 2016, at 17:38, Jens Alfke wrote: > I believe Mac/iOS developers usually transfer the entire file because that’s > the particular hammer that Foundation provides. I disagree. One-shot file system APIs make sense for a lot of reasons: * It’s generally easier to use. Consider NSXMLD