Re: [swift-users] Making a copy of an UnsafePointer

2017-11-15 Thread Quinn ";The Eskimo!" via swift-users
On 15 Nov 2017, at 04:16, Rick Mann via swift-users wrote: > Is UnsafeMutablePointer<> not memory managed? It is not. Specifically, the code you posted creates a copy of the data and then never destroys it. If I were in your shoes I’d construct a `Data` value from

Re: [swift-users] Was the String contains(_:) method changed in Swift 4?

2017-11-08 Thread Quinn ";The Eskimo!&quot; via swift-users
On 8 Nov 2017, at 09:28, Martin R wrote: > Unicode correct string comparison _is_ tricky … Indeed, apparently so tricky I can’t type my tests in properly )-: Share and Enjoy -- Quinn "The Eskimo!" Apple Developer

Re: [swift-users] Optimal String conversion to/from UTF-8 w/o null-termination?

2017-11-06 Thread Quinn ";The Eskimo!&quot; via swift-users
On 6 Nov 2017, at 17:21, Kelvin Ma via swift-users wrote: > doesn’t the compiler like to optimize the loop out of the benchmarking code? Yep. I would resolve this by reading the input from a file. For example, in the data-to-String case, you could: 1. Read lots of

Re: [swift-users] Optimal String conversion to/from UTF-8 w/o null-termination?

2017-11-06 Thread Quinn ";The Eskimo!&quot; via swift-users
On 3 Nov 2017, at 19:42, Jens Alfke via swift-users wrote: > Any way to pass the bytes directly to String without an intermediate copy? You can do this with `UnsafeBufferPointer`. For example: extension String { init?(bytes: UnsafePointer, count: Int) {

Re: [swift-users] Restrict parameter to value type

2017-10-19 Thread Quinn ";The Eskimo!&quot; via swift-users
On 19 Oct 2017, at 11:47, Martin Knabbe via swift-users wrote: > I'm curious why AnyValue is missing. Can someone answer this? This question has come up a number of times, including this recent thread on swift-dev.

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-18 Thread Quinn ";The Eskimo!&quot; via swift-users
On 18 Sep 2017, at 13:52, Vladimir.S wrote: > Can't understand/accept this, sorry. You seem to be very invested in how Swift /should/ work, rather than how it /does/ work. I’m sympathetic with that position but it’s really a topic of conversation for swift-evolution rather

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-17 Thread Quinn ";The Eskimo!&quot; via swift-users
On 15 Sep 2017, at 21:35, Vladimir.S via swift-users wrote: > … for me it is very strange decision to disallow a method because it is > 'expensive'. That’s pretty normal for Swift standard library protocols, which define not just the behaviour of the routine but

Re: [swift-users] Swift 4 "Cannot use mutating member on immutable value: 'self' is immutable"

2017-09-14 Thread Quinn ";The Eskimo!&quot; via swift-users
On 14 Sep 2017, at 03:56, somu subscribe via swift-users wrote: > popFirst is not available in the Array … Right. This makes sense when you consider the standard setup for an array, namely, a variable length buffer of items. Removing the first element is expensive,

Re: [swift-users] Memory Address of value types and reference types

2017-09-12 Thread Quinn ";The Eskimo!&quot; via swift-users
On 12 Sep 2017, at 13:44, somu subscribe via swift-users wrote: > 1. Is the above shown the correct way to get reference type memory address ? > 2. What Is it the correct way to get value type memory address ? It’s hard to answer that without knowing how you’re intended

Re: [swift-users] Writing a pod catcher for iOS

2017-09-04 Thread Quinn ";The Eskimo!&quot; via swift-users
On 1 Sep 2017, at 20:02, Nicholas Acosta via swift-users wrote: > Now, I want to take it to the next level and create my own pod cast/RSS > reader for the iPhone. This is more about Apple frameworks than it is about Swift, so you might have better luck asking this

Re: [swift-users] [Swift Package Manager] Use of Info-plist; use for apps

2017-08-22 Thread Quinn ";The Eskimo!&quot; via swift-users
On 22 Aug 2017, at 06:13, Daryle Walker via swift-users wrote: > I recall there’s a way to make a command-line tool in macOS have an > “Info.plist” file, which is compiled/linked in the executable’s data segment. Correct. Xcode has explicit support for this, namely

Re: [swift-users] Simultaneous accesses, but modification requires exclusive access

2017-07-24 Thread Quinn ";The Eskimo!&quot; via swift-users
On 24 Jul 2017, at 07:04, somu subscribe via swift-users wrote: > - Is there a bug in my code which is being detected in Xcode 9 ? Yes. The problem here is that `doSomething(f1:)` is a mutating function, so it acts like it takes an `inout` reference to `self.helper`.

Re: [swift-users] There is a way to see pending features or discussions in complexity order?

2017-06-12 Thread Quinn ";The Eskimo!&quot; via swift-users
On 11 Jun 2017, at 09:02, Mariano Cornejo Herrera via swift-users wrote: > There is a way to see pending features or discussions in complexity order? I’m not sure what you’re asking for here. Are you looking for some way to contribute to the Swift open source efforts?

Re: [swift-users] DateFormatter bug

2017-05-16 Thread Quinn ";The Eskimo!&quot; via swift-users
On 16 May 2017, at 00:53, Ronaldo Faria Lima via swift-users wrote: > There is another important fact: 15 of October is when day light savings is > effective in Brazil. Which means there’s no midnight on that day, right? Last time I encountered this it was caused by

Re: [swift-users] Making Error sub-enums Equatable

2017-05-10 Thread Quinn ";The Eskimo!&quot; via swift-users
On 10 May 2017, at 09:23, Brent Royal-Gordon via swift-users wrote: > (given your "ignore the associated type" semantic) This is the bit that worries me. The docs for `Equatable` are very clear that it implies /substitutability/, which is not the case if you ignore

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-28 Thread Quinn ";The Eskimo!&quot; via swift-users
On 28 Apr 2017, at 09:10, Quinn The Eskimo! via swift-users <swift-users@swift.org> wrote: > * If the memory is in a zone that uses fixed sized buckets, it may not be > possible to reduce the memory that you freed by reducing the size D’oh! For “to reduce the memory” re

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-28 Thread Quinn ";The Eskimo!&quot; via swift-users
On 28 Apr 2017, at 03:09, Rick Mann via swift-users wrote: > Because this runs on iOS, I'd like to reduce the amount of time I hang on to > memory as much as possible (there's a lot of parallel processing happening in > our pipeline). I'd also like to avoid copying the

Re: [swift-users] Core Graphics drawing a bitmap

2017-04-24 Thread Quinn ";The Eskimo!&quot; via swift-users
On 23 Apr 2017, at 06:11, Don Giovanni via swift-users wrote: > I'm trying to use Core Graphics to draw to a UIView. swift-users isn’t really the right place for questions related to Apple frameworks. You might be better off asking this in a different context, such

Re: [swift-users] Swift version of C #defines

2017-04-21 Thread Quinn ";The Eskimo!&quot; via swift-users
On 21 Apr 2017, at 11:03, Rick Mann via swift-users wrote: > It seems Swift (in Xcode 8.3.2) can't generate symbols for #defines that have > expressions. Correct. There’s various bugs on file about this already but SR-485 is a good place to start.

Re: [swift-users] String init from Int8 tuple?

2017-04-19 Thread Quinn ";The Eskimo!&quot; via swift-users
On 19 Apr 2017, at 09:14, Martin R wrote: > Some authoritative response from SwiftLand™ would be much appreciated. I still don’t work on the Swift compiler (-: but I thought I’d share this quote that recently came by on swift-evolution: On 17 Apr 2017, at 22:18, Michael

Re: [swift-users] String init from Int8 tuple?

2017-04-19 Thread Quinn ";The Eskimo!&quot; via swift-users
On 19 Apr 2017, at 02:11, Rick Mann via swift-users wrote: > In my C-interop, I have a need to do this a lot: I think you’re working too hard here. Try this: func callbackFailed(info inInfo: lgs_result_info_t) { var m = inInfo.message let message =

Re: [swift-users] Xcode Windows

2017-04-13 Thread Quinn ";The Eskimo!&quot; via swift-users
On 13 Apr 2017, at 10:12, LAURENT Charles via swift-users wrote: > How to proceed next to get a single window ? You might have more luck asking this in a context dedicate to Cocoa programming, like this cocoa-dev mailing or the Cocoa topic area on DevForums.

Re: [swift-users] Generic and Nested Types

2017-03-23 Thread Quinn ";The Eskimo!&quot; via swift-users
On 23 Mar 2017, at 08:55, Седых Александр via swift-users wrote: > Please explain me, why we can't make Nested Types in Generic Types? I believe you can in the latest Xcode 8.3 beta. This is courtesy of SR-1446. Share and

Re: [swift-users] Self - requirement

2017-03-14 Thread Quinn ";The Eskimo!&quot; via swift-users
On 14 Mar 2017, at 06:02, Седых Александр via swift-users wrote: > Please, tell, where I can read about "Self" requirement in protocols? The thing that really clarified it for me was Dave Abrahams’s classic “Protocol-Oriented Programming in Swift” talk from WWDC 2016.

Re: [swift-users] Using withUnsafePointer on char arrays within C structs

2017-02-23 Thread Quinn ";The Eskimo!&quot; via swift-users
On 23 Feb 2017, at 10:31, Martin R wrote: > Is that simplified guaranteed to work? Based on a previous conversation I had with the Swift folks about this, yes. However, I don’t work on the compiler so it’s possible I misunderstood. Perhaps someone from SwiftLand™ will

Re: [swift-users] Using withUnsafePointer on char arrays within C structs

2017-02-23 Thread Quinn ";The Eskimo!&quot; via swift-users
On 22 Feb 2017, at 22:16, Russell Finn via swift-users wrote: > … is (2) the best I can do for now? Yes. btw You can simplify the code to this: var description: String { var tmp = self.path return String(cString: ) } but it still needs that

Re: [swift-users] How to return value in void * C pointer ?

2017-02-16 Thread Quinn ";The Eskimo!&quot; via swift-users
On 16 Feb 2017, at 15:59, Biala via swift-users wrote: > I have to implement a callback method that is called by the API. As a > variable I get a class with void * member. I have to allocate some object in > memory and assign this void* member to point to it. I don’t

Re: [swift-users] Question about text colouring in NSTextView

2017-02-06 Thread Quinn ";The Eskimo!&quot; via swift-users
On 6 Feb 2017, at 19:16, Jens Alfke via swift-users wrote: > Apple developer lists have been offline for more than a week them. This is being investigated (INC063170897). Share and Enjoy -- Quinn "The Eskimo!" Apple

Re: [swift-users] @NSCopying semantic does not appear to copy in Swift initializer

2017-01-30 Thread Quinn ";The Eskimo!&quot; via swift-users
On 30 Jan 2017, at 10:12, Torin Kwok wrote: > In Obj-C, if a property has promised that it conforms to > porotocl and that it would respect copying semantic by being qualified > with `@property (copy)`, then we assign a value to `ivar` through the > setter by writting down

Re: [swift-users] @NSCopying semantic does not appear to copy in Swift initializer

2017-01-30 Thread Quinn ";The Eskimo!&quot; via swift-users
On 27 Jan 2017, at 18:56, Jordan Rose via swift-users wrote: > @NSCopying currently does not affect initializers. … it's not 100%, for-sure > a bug. Just by way of context, this current behaviour closely matches Objective-C conventions, where `-init` methods directly

Re: [swift-users] Callback in Swift

2017-01-25 Thread Quinn ";The Eskimo!&quot; via swift-users
On 25 Jan 2017, at 07:49, John Brownie via swift-users wrote: > My macOS app shows a representation of the contents of various folders, so > using FSEvents to track modifications from outside the app seemed to be the > way to go. I am running into difficulty with

Re: [swift-users] ranges and min

2017-01-23 Thread Quinn ";The Eskimo!&quot; via swift-users
On 23 Jan 2017, at 14:58, J.E. Schotsman via swift-users wrote: > This doesn’t compile … How are you testing this? I replaced the `main.swift` of a new test tool project (in Xcode 8.2, choose Xcode > New > Project > macOS > Command Line Tool) and it compiled without

Re: [swift-users] Why this string not work. Any and Optionals in dictionary

2017-01-23 Thread Quinn ";The Eskimo!&quot; via swift-users
On 23 Jan 2017, at 10:24, Седых Александр via swift-users wrote: > I have a simple expression with Any and is not work. Why? The problem here is that: * `nil` is syntactic sugar for `Optional.none`, where `Optional` is generic on the `Wrapped` type * You’re not given

Re: [swift-users] enum compare

2017-01-23 Thread Quinn ";The Eskimo!&quot; via swift-users
On 21 Jan 2017, at 12:56, tridiak via swift-users wrote: > How do I fix this? Simply cannot see it. Use a switch statement: switch type { case .noType, .dodge, .other: return true case .natural, .armour, .shield, .deflection, .sacred, .luck: return false } Note

Re: [swift-users] for i in 0...UInt8.max

2017-01-11 Thread Quinn ";The Eskimo!&quot; via swift-users
On 11 Jan 2017, at 13:06, tuuranton--- via swift-users wrote: > These codes used to crash in earlier Swifts. Can you explain why? We now have the notion of `ClosedRange`, which can represent all values in an integer type (at the cost of introducing the complexity of

Re: [swift-users] Bls: Bls: GCD and Process

2017-01-09 Thread Quinn ";The Eskimo!&quot; via swift-users
On 9 Jan 2017, at 05:56, Mr Bee wrote: > How to do such a trick? By calling `dispatchMain()` or one of the various functions that calls `dispatchMain()`. There’s no lower-level interface to this. Share and Enjoy -- Quinn "The Eskimo!"

Re: [swift-users] module (de)-initialization

2016-12-20 Thread Quinn ";The Eskimo!&quot; via swift-users
On 19 Dec 2016, at 08:37, Mr Bee via swift-users wrote: > 1. Is there any module initialization and deinitialization concept in Swift > (v.3)? No. For initialisation, the standard approach in Swift is to exploit the fact that globals are initialised lazily on first

Re: [swift-users] C unsigned int[] imported as tuple?

2016-10-31 Thread Quinn ";The Eskimo!&quot; via swift-users
On 29 Oct 2016, at 11:34, Thierry Passeron via swift-users wrote: > For me this tuple should have been at least imported with named fields or > even better as [UInt32] array... The latter is not possible because Swift does not currently have support for fixed-size

Re: [swift-users] NSFontManager's availableMembers(ofFontFamily: String) broken?

2016-10-09 Thread Quinn ";The Eskimo!&quot; via swift-users
On 8 Oct 2016, at 07:41, Jens Persson via swift-users wrote: > Found this: > http://stackoverflow.com/questions/39395237/why-is-nsfontmanager-availablemembersoffontfamily-crashing-in-xcode-8-gm > >

Re: [swift-users] DispatchQueue extension

2016-10-07 Thread Quinn ";The Eskimo!&quot; via swift-users
On 6 Oct 2016, at 20:20, Nick Brook via swift-users wrote: > I have an extension on DispatchQueue and I have Objective-C code which uses > my swift code, so the DispatchQueue extension is exported to the Swift > objective-c header as > > @interface OS_dispatch_queue >

Re: [swift-users] UnsafeMutablePointer on the stack?

2016-10-03 Thread Quinn ";The Eskimo!&quot; via swift-users
On 3 Oct 2016, at 01:14, Mike Ferenduros via swift-users wrote: > Personally I would be surprised if the malloc caused an actual measurable > performance hit tbh. Quite. SecRandom generates cryptographically sound random numbers and thus is not optimised for speed.

Re: [swift-users] CharacterSet vs Set

2016-10-03 Thread Quinn ";The Eskimo!&quot; via swift-users
On 2 Oct 2016, at 19:02, Jean-Denis Muys via swift-users wrote: > The problem is, I could not find a simple way to convert from a character to > a unicodeScalar. As is often the case with string examples, it would help if you posted more about your context. With the

Re: [swift-users] Swift 3 version of creating a string from a pointer, length and encoding?

2016-09-30 Thread Quinn ";The Eskimo!&quot; via swift-users
On 29 Sep 2016, at 10:47, John Brownie via swift-users wrote: > Or is there a better way that I've missed (highly possible)? I don’t think there’s anything significantly better. The other two options I can think of: * use the `UTF8` codec * use NSString

Re: [swift-users] Updating C-wrapper to Swift 3

2016-09-28 Thread Quinn ";The Eskimo!&quot; via swift-users
On 28 Sep 2016, at 07:29, John Brownie via swift-users wrote: > Where can I read up on how to make the conversion? I recommend reading the whole “Migrating to Swift 2.3 or Swift 3 from Swift 2.2” doc, but for this specific issue you should start with the

Re: [swift-users] IOKit and USB devices with swift 3

2016-09-26 Thread Quinn ";The Eskimo!&quot; via swift-users
On 26 Sep 2016, at 10:48, Quinn The Eskimo! via swift-users <swift-users@swift.org> wrote: > Next, unless you absolutely have to, I’d avoid getting between > IOServiceMatching and IOServiceAddMatchingNotification. These two have > unusual memory management behaviour (IO

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Quinn ";The Eskimo!&quot; via swift-users
On 23 Sep 2016, at 11:29, Gerriet M. Denkmann via swift-users wrote: > What about calloc then? Or use allocate and do a memset afterwards? For trivial data types (like UInt8) this will work, but if you want to follow the rules I recommend reading the following: *

Re: [swift-users] Canonical way to cast C structs

2016-09-21 Thread Quinn ";The Eskimo!&quot; via swift-users
On 21 Sep 2016, at 06:45, Bouke Haarsma via swift-users wrote: > This property is not available on Linux … Hey, it’s call /BSD/ Sockets for a reason (-: Honestly, I don’t think there’s a good way to maintain the simplicity of this abstraction without `ss_len`.

Re: [swift-users] Problem calling a C function passing a void** from Swift 3

2016-09-16 Thread Quinn ";The Eskimo!&quot; via swift-users
On 15 Sep 2016, at 22:11, Lane Schwartz via swift-users wrote: > Can anyone help me get the equivalent functionality in Swift 3? I think the main issue here is that, in Swift 3, unsafe pointers, in their various flavours, don’t explicitly support nil. Rather, nil is

Re: [swift-users] Vague error description when trying to match an instance in a switch statement

2016-09-16 Thread Quinn ";The Eskimo!&quot; via swift-users
On 15 Sep 2016, at 19:53, hello--- via swift-users wrote: > It would be nice if the error message could be improved to spare confusion for > the other developers. Indeed. If you can file a bug about this, that’d be grand. Share and Enjoy --

Re: [swift-users] Swift and Threads

2016-09-13 Thread Quinn ";The Eskimo!&quot; via swift-users
On 13 Sep 2016, at 05:03, Gerriet M. Denkmann via swift-users wrote: > Or is the code fundamentally wrong …? This one. You’re accessing a mutable value (`bitfield`) from multiple threads. Swift does not support that, even in situations like this where you’re sure

Re: [swift-users] Canonical way to cast C structs

2016-09-12 Thread Quinn ";The Eskimo!&quot; via swift-users
On 12 Sep 2016, at 20:39, Bouke Haarsma via swift-users wrote: > So the question remains on how to perform the casts using Swift? In general it’s best to avoid special casing your network protocols. The best option for doing that is and calls. Specifically, with

Re: [swift-users] Lazy expression is ambiguous?

2016-09-12 Thread Quinn ";The Eskimo!&quot; via swift-users
On 12 Sep 2016, at 09:20, Rick Mann wrote: > I've always wondered why that was the case. Implementing `dispatch_once` so that it’s fast on all CPU architectures, including those with a weak memory model, requires that ‘once token’: * be initialised to 0 before

Re: [swift-users] Lazy expression is ambiguous?

2016-09-12 Thread Quinn ";The Eskimo!&quot; via swift-users
On 12 Sep 2016, at 08:53, Quinn The Eskimo! via swift-users <swift-users@swift.org> wrote: > On 12 Sep 2016, at 08:46, Rick Mann <rm...@latencyzero.com> wrote: > >> I had assumed lazy worked like static, which I understand uses dispatch_once >> under the h

Re: [swift-users] Lazy expression is ambiguous?

2016-09-12 Thread Quinn ";The Eskimo!&quot; via swift-users
On 12 Sep 2016, at 08:46, Rick Mann wrote: > I had assumed lazy worked like static, which I understand uses dispatch_once > under the hood. Correct. [I’m not sure if it actually /uses/ `dispatch_once` specifically, but it has the same semantics.] > Would that be a

Re: [swift-users] Lazy expression is ambiguous?

2016-09-12 Thread Quinn ";The Eskimo!&quot; via swift-users
On 12 Sep 2016, at 08:28, Zhao Xin wrote: > It is not a bug. I disagree. > You must explicitly specify the variable's type if you use `lazy` keyword. No, that’s not the case in general. For example, the following code compiles just fine. import Dispatch func

Re: [swift-users] Lazy expression is ambiguous?

2016-09-12 Thread Quinn ";The Eskimo!&quot; via swift-users
On 12 Sep 2016, at 06:40, Jacob Bandes-Storch via swift-users wrote: > I'd recommend filing a bug at bugs.swift.org. Agreed. Also, you can work around this by adding a type. lazy var myQ: DispatchQueue = DispatchQueue(label: "Op", attributes: .concurrent) Also,

Re: [swift-users] tuples and metatypes

2016-08-31 Thread Quinn ";The Eskimo!&quot; via swift-users
On 31 Aug 2016, at 02:38, Ray Fix via swift-users wrote: > Is it correct to say that this is true because there is not a unique metatype > for compound types? The way I’ve seen this explained is that tuples are "structural types" (their compatibility is determined by

Re: [swift-users] No hex dump anymore in Data description

2016-08-29 Thread Quinn ";The Eskimo!&quot; via swift-users
On 27 Aug 2016, at 07:45, Martin R via swift-users wrote: > Is it intentional that the description method of Data returns only the number > of bytes, but not a hex dump of the contents (as NSData did)? It doesn’t really matter if it was intentional or not; if it’s

Re: [swift-users] How to build a CLI tool which links a Swift framework? (OSX)

2016-08-25 Thread Quinn ";The Eskimo!&quot; via swift-users
On 25 Aug 2016, at 11:28, Karl via swift-users wrote: > I’m having a problem getting the framework and CLI tool to work together, > because of the Swift standard libraries … Yep, I know this problem well. What I do is use Xcode to create an app target, remove all the

Re: [swift-users] Regression in Xcode8-beta6 Swift?

2016-08-25 Thread Quinn ";The Eskimo!&quot; via swift-users
On 25 Aug 2016, at 08:23, David Hart via swift-users wrote: > You can’t call arbitrary functions on AnyObject anymore. You’re mixing up `Any` and `AnyObject`. You can still call arbitrary methods on `AnyObject`, as Martin demonstrated, but Travis’s error message

Re: [swift-users] Pointer conversions between different sockaddr types

2016-08-22 Thread Quinn ";The Eskimo!&quot; via swift-users
On 18 Aug 2016, at 08:28, Quinn The Eskimo! via swift-users <swift-users@swift.org> wrote: > In my case I introduced an abstract `Address` type (basically a wrapper > around `sockaddr_storage`) and then added a method to that object which calls > a closure with the right param

Re: [swift-users] Pointer conversions between different sockaddr types

2016-08-18 Thread Quinn ";The Eskimo!&quot; via swift-users
On 17 Aug 2016, at 18:55, Martin R via swift-users wrote: > - Are both solutions correct, should one be preferred, or are both wrong? Your `withMemoryRebound` solution is correct. > - Can the same be achieved simpler? Not without introducing a layer of abstraction.

Re: [swift-users] NSData vs Data in swift 3

2016-08-12 Thread Quinn ";The Eskimo!&quot; via swift-users
On 12 Aug 2016, at 05:00, CK TUNG via swift-users wrote: > Any idea on the motivation to have new Data class in Foundation ? For the motivation behind these changes, check out the following Swift evolution proposals: * SE-0069 “Mutability and Foundation Value Types”

Re: [swift-users] Two Obj-C visible functions no longer overload?

2016-08-08 Thread Quinn ";The Eskimo!&quot; via swift-users
On 5 Aug 2016, at 22:57, Jon Shier via swift-users wrote: > Now, if I mark one of the functions @nonobjc, it compiles. So is this a bug > or change in behavior? NSOperation has a property with `-finished:` as the setter and `-isFinished` as the getter. It’s not

Re: [swift-users] Compact iteration of optional collection?

2016-07-29 Thread Quinn ";The Eskimo!&quot; via swift-users
On 28 Jul 2016, at 22:55, Rick Mann via swift-users wrote: > I often call methods that return an optional collection. Why do these methods return an optional collection rather an empty collection? Back in the day Cocoa code used to work that way because constructing

Re: [swift-users] Should a queue be value type or reference type?

2016-07-26 Thread Quinn ";The Eskimo!&quot; via swift-users
On 25 Jul 2016, at 15:10, 褚 晓敏 via swift-users wrote: > So what should it be, according to API design guidelines? It’s hard to answer this question without more information about your specific context. However, I think it’s safe to say that Swift expresses a preference

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

2016-06-06 Thread Quinn ";The Eskimo!&quot; via swift-users
On 5 Jun 2016, at 11:36, Jens Alfke wrote: > It’s almost unique in that regard; in general Cocoa APIs are only supposed to > throw exceptions for programmer errors like assertion failures. Almost unique is right. The only other offender I can think of is Distributed

Re: [swift-users] Simple text file I/O with Swift 3

2016-05-30 Thread Quinn ";The Eskimo!&quot; via swift-users
On 28 May 2016, at 19:05, Ken Burgett via swift-users wrote: > print(buf) The trick here is to replace the above line with: print(String(validatingUTF8: buf)) `fgets` sets up `buf` to hold a C string, so you have to convert it to a Swift string. How do you do

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

2016-05-23 Thread Quinn ";The Eskimo!&quot; via swift-users
On 18 May 2016, at 23:02, John Myers via swift-users wrote: > I've been having trouble figuring out how to read and write data to a > textfile, and not finding much out there for Swift on Linux. Sorry about being complicit in the one-shot vs streaming I/O diversion.

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

2016-05-19 Thread Quinn ";The Eskimo!&quot; via swift-users
On 18 May 2016, at 23:02, John Myers via swift-users wrote: > I've been having trouble figuring out how to read and write data to a > textfile … Your examples show you transferring the data line-by-line. Is that the end goal? Or just fallout from what you happened

Re: [swift-users] CGPathApply

2016-05-13 Thread Quinn ";The Eskimo!&quot; via swift-users
On 13 May 2016, at 06:24, Zach Waldowski via swift-users wrote: > Problems are just like any context-based C API, you need to squeeze all … and the best way to do that is to use a closure. typealias CGPathApplierBlock = @convention(block) (CGPathElement) -> Void func

Re: [swift-users] Illegal Instruction: 4 OS X libdispatch

2016-05-02 Thread Quinn ";The Eskimo!&quot; via swift-users
On 1 May 2016, at 19:33, Tyler Fleming Cloutier via swift-users wrote: > I’m creating a Swift package that uses Dispatch on OS X, but I am getting an > Illegal Instruction error after I register my block for an event. > Specifically, a UD2 instruction inside of