Re: [swift-users] inout params seem to have undefined behavior

2016-06-11 Thread David Sweeris via swift-users
Ack! “Karl”, not you. For some reason I thought you were the OP until right after I clicked send. Sorry for the confusion. - Dave Sweeris > On Jun 11, 2016, at 4:06 PM, David Sweeris via swift-users > <swift-users@swift.org> wrote: > >> >> On Jun 11, 2016

Re: [swift-users] inout params seem to have undefined behavior

2016-06-12 Thread David Sweeris via swift-users
Oh, ok, I stand corrected. Thanks for the link :-) Sent from my iPhone On Jun 11, 2016, at 18:05, Brent Royal-Gordon wrote: >> My recollection is that in Swift the subscript operator (`arr[2]` in this >> case) can refer to the setter xor the getter, but not both within

Re: [swift-users] Trouble constraining a generic type in an extension

2016-04-12 Thread David Sweeris via swift-users
Bool isn’t a class (or protocol), so nothing can inherit from it. Until Swift gains the ability to extend generic types where their parameters are *equal* to concrete types, as opposed to where they *inherit from or conform to* something, I think the best you can do is this: public extension

Re: [swift-users] Generators vs. errors

2016-04-12 Thread David Sweeris via swift-users
I think I’d either just end the sequence on an error, or do like you were thinking and have a function/computed property that gives an array containing all the rows which had an error or something. I’m not a DB guy, though. - Dave Sweeris > On Apr 12, 2016, at 1:53 PM, Jens Alfke via

Re: [swift-users] Stored Property, Externally Read-Only

2016-04-29 Thread David Sweeris via swift-users
Yep, declare it like this: public private(set) var lastUpdated: NSDate? At least I’m pretty sure that’s the syntax. I don’t have Xcode in front of me to double-check. HTH - Dave Sweeris > On Apr 29, 2016, at 9:52 AM, Bob Davidson via swift-users > wrote: > >

Re: [swift-users] Can't declare variable with same name as func called to assign its initial value

2016-05-12 Thread David Sweeris via swift-users
I can't recall whether functions and variables can have the same name (though I think not), but at the least that error message seems to miss the point. Sent from my iPhone > On May 12, 2016, at 14:07, Evan Maloney via swift-users > wrote: > > Adopting the newer Swift

Re: [swift-users] Dictionary with optional values

2016-05-18 Thread David Sweeris via swift-users
I'm not in front of Xcode, so I can't confirm this, but I suspect that `optDict["one"] = nil as! Int?` will set "one" to nil, rather than removing "one". Whatever the rules for inferring the type of `nil` when an Optional is involved are, it seems like it always infers the one I don't want.

Re: [swift-users] Range.count can abort

2016-04-16 Thread David Sweeris via swift-users
Is there any reason that Distance has to be a simple Int? Since it’s defined per-type, UInt64 could use a custom struct without impacting the performance of other types: struct UInt64Distance : Comparable { //I'm not sure what else it needs to conform to var distance: UInt64 var

Re: [swift-users] Nil coalescing operator (??) and function vars

2016-04-18 Thread David Sweeris via swift-users
Looks like a bug to me. You can work around it either by substituting the long version: let fn:(String) -> String = x != nil ? x! : qq or by declaring qq & fn like this: let qq:(String -> String)? = { _ in return "..." } let fn:String -> String = (x ?? qq)! or like this: let qq:(String ->

Re: [swift-users] Protocol with instance var that's set on construction, otherwise read-only

2016-08-02 Thread David Sweeris via swift-users
If I understand things correctly, you *can* make uuid a let because you’re allowed to set them (once) during init functions. - Dave Sweeris > On Aug 2, 2016, at 6:22 PM, Rick Mann via swift-users > wrote: > > I'm trying to define a protocol that has a read-only,

Re: [swift-users] Protocol with instance var that's set on construction, otherwise read-only

2016-08-02 Thread David Sweeris via swift-users
Oh, it's a computed property! Got it, I thought you meant its value was computed in the init and never changed again. Sent from my iPhone > On Aug 2, 2016, at 19:01, Rick Mann wrote: > > It complains if I make it a let because computed properties must be var. > Because

Re: [swift-users] Why can't structs inherit from other structs?

2016-08-02 Thread David Sweeris via swift-users
> On Aug 2, 2016, at 4:03 AM, Tino Heth via swift-users > wrote: > > There is no fundamental reason to disallow struct inheritance, and I started > a pitch where afair one member of core agreed it would be useful — I hope > there is time to add it in the next year. >

Re: [swift-users] Swift in bare-metal embedded programming/Swift runtime

2016-08-10 Thread David Sweeris via swift-users
There's definitely a runtime, but I *think* you can avoid actually using it by being very careful with your data structures. ARC means that classes obviously trigger it, and I think it *might* be involved resizing arrays and strings (they do some tricks behind the scenes, but I can't remember

Re: [swift-users] Why can't Swift instance methods call class methods without qualification?

2016-06-30 Thread David Sweeris via swift-users
I'm pretty sure you can have instance and static methods with the same name. Requiring `Type.foo()` instead of just `foo()` would tell the compiler which one you want. - Dave Sweeris > On Jun 30, 2016, at 21:01, Rick Mann via swift-users > wrote: > > >> On Jun 30,

Re: [swift-users] Plan to move swift-evolution and swift-users mailing lists to Discourse

2017-02-19 Thread David Sweeris via swift-users
Sent from my iPhone > On Feb 19, 2017, at 13:41, Lane Schwartz via swift-users > wrote: > > Hi all, > > I'm sure there are good reasons for this switch. Personally, I strongly > prefer email lists to forums. > > This move will make it harder for me to participate

Re: [swift-users] question on generics

2017-02-22 Thread David Sweeris via swift-users
> On Feb 22, 2017, at 16:08, Dave Reed via swift-users > wrote: > > I suspect this can't be done (at least not right now), but wanted to check. > > I'd like to declare a class as a generic that meets a protocol and is also a > subclass of some specific type. > >

Re: [swift-users] Plan to move swift-evolution and swift-users mailing lists to Discourse

2017-02-09 Thread David Sweeris via swift-users
> On Feb 9, 2017, at 09:30, Matthew Johnson via swift-users > wrote: > > >>> On Feb 9, 2017, at 11:16 AM, Jens Alfke via swift-users >>> wrote: >>> >>> >>> On Feb 9, 2017, at 3:41 AM, Jan Neumüller via swift-users >>>

Re: [swift-users] Swift in bare-metal embedded programming/Swift runtime

2016-08-15 Thread David Sweeris via swift-users
r amount of work, but I think the first step could be to add >> compiler flags where calls to runtime functions become diagnostics. Again >> though, I’m not sure how much effort it would take to eliminate them >> completely. >> >> Slava >> >>> On A

Re: [swift-users] Decimal to Double?

2016-11-28 Thread David Sweeris via swift-users
> On Nov 28, 2016, at 13:43, Joe Groff via swift-users > wrote: > > >> On Nov 28, 2016, at 11:42 AM, Nevin Brackett-Rozinsky >> wrote: >> >> On Mon, Nov 28, 2016 at 2:21 PM, Joe Groff via swift-users >>

Re: [swift-users] Decimal to Double?

2016-11-28 Thread David Sweeris via swift-users
Sent from my iPhone > On Nov 28, 2016, at 13:21, Joe Groff wrote: > > It really shouldn't be, since ExpressibleByFloatLiteral uses a binary float > initial value and so doesn't guarantee decimal accuracy. I'd recommend using > init(mantissa:exponent:isNegative:) instead,

Re: [swift-users] Workaround for generics not currently supporting conditional conformance to a protocol

2016-11-16 Thread David Sweeris via swift-users
> On Nov 16, 2016, at 16:35, Jordan Rose <jordan_r...@apple.com> wrote: > > >>> On Nov 16, 2016, at 7:35, David Sweeris via swift-users >>> <swift-users@swift.org> wrote: >>> >>> >>> On Nov 15, 2016, at 11:55 PM, Howard Lovat

Re: [swift-users] Reflection in Swift 3?

2016-11-12 Thread David Sweeris via swift-users
> On Nov 13, 2016, at 00:38, Rick Mann via swift-users > wrote: > > So, it seems there's still no way to do something like instantiate a class > given only its name (as a String)? > > In my situation, I have a number of subclasses (or protocol implementations), >

Re: [swift-users] Optimising Set comparisons

2016-11-13 Thread David Sweeris via swift-users
> On Nov 13, 2016, at 1:58 PM, Nial Giacomelli via swift-users > wrote: > > Using Swift 3 I have a function that's called extremely frequently and is > appearing regularly in Profiler runs. The function takes two Set > instances and simply attempts to determine whether

Re: [swift-users] Reflection in Swift 3?

2016-11-13 Thread David Sweeris via swift-users
> On Nov 13, 2016, at 1:55 AM, Rick Mann wrote: > > >> On Nov 12, 2016, at 22:47 , David Sweeris wrote: >> >> >>> On Nov 13, 2016, at 00:38, Rick Mann via swift-users >>> wrote: >>> >>> So, it seems there's still no way

Re: [swift-users] Overload Resolution of Binary Operators

2016-11-14 Thread David Sweeris via swift-users
> On Nov 14, 2016, at 16:05, Toni Suter via swift-users > wrote: > > Hi, > > I would have expected that the following code reports an error, because > of ambiguous function overloads: > > infix operator ***: MultiplicationPrecedence > infix operator +++:

Re: [swift-users] Implicitly capture a mutating self

2016-12-16 Thread David Sweeris via swift-users
> On Dec 16, 2016, at 15:54, Richard Wei via swift-users > wrote: > > Thanks. That’s true, but there are cases (like making BLAS calls) where I > have to nest more than 4 `withUnsafeMutable…` closures. It’s safe by really > clumsy. I just wish there were a cleaner way

Re: [swift-users] [swift-build-dev] Importing C system libraries

2017-03-28 Thread David Sweeris via swift-users
> On Mar 28, 2017, at 1:58 AM, Rien via swift-build-dev > wrote: > > I feel your pain ;-) > > Just embrace the dark side, it takes a little time to get used to, but > chances are you won’t regret it. > > Btw: I still do my development in Xcode, its just that using

Re: [swift-users] Why does this leak?

2017-03-27 Thread David Sweeris via swift-users
Could you call the supposedly leaky code a few million times and look at memory usage to see if there's actually a leak? - Dave Sweeris > On Mar 27, 2017, at 13:31, Rick Aurbach via swift-users > wrote: > > Okay, I downloaded the latest Xcode from the developer site.

Re: [swift-users] Swift 3.1 String(

2017-04-05 Thread David Sweeris via swift-users
> On Apr 5, 2017, at 07:49, Rien via swift-users wrote: > > >> On 05 Apr 2017, at 16:26, Maxim Veksler via swift-users >> wrote: >> >> Hi, >> >> Swift 3.1 compiler seems to introduces a new complier warning regarding >> String(describing: ) >>

[swift-users] Quick Question about ExpressibleByStringLiteral

2017-03-09 Thread David Sweeris via swift-users
If my type doesn’t know/care about the difference between a normal “String" and an “ExtendedClusterScalarGraphemeLiteralUnicodeTypeCluster” (or whatever those other literal types are called), is there anything wrong with doing this? public protocol EasilyExpressibleByStringLiteral :

Re: [swift-users] Quick Question about ExpressibleByStringLiteral

2017-03-09 Thread David Sweeris via swift-users
ordan > >> On Mar 9, 2017, at 17:59, David Sweeris via swift-users >> <swift-users@swift.org <mailto:swift-users@swift.org>> wrote: >> >> If my type doesn’t know/care about the difference between a normal “String" >> and an “ExtendedCluster

Re: [swift-users] Anyone else having trouble getting swift to build?

2017-03-05 Thread David Sweeris via swift-users
t 3:03 PM, David Sweeris via swift-users >> <swift-users@swift.org> wrote: >> In particular, the "utils/build-script -x” will fail with 84 errors on my >> system. As best as I can tell, they're all/mostly linker errors because the >> correct .dylib files aren't be

[swift-users] Anyone else having trouble getting swift to build?

2017-03-05 Thread David Sweeris via swift-users
In particular, the "utils/build-script -x” will fail with 84 errors on my system. As best as I can tell, they're all/mostly linker errors because the correct .dylib files aren't being created (not sure why there wouldn’t be errors from that, but I don’t see any)? Is there an option to not

Re: [swift-users] is this a defect in equatable for swift tuples?

2017-07-09 Thread David Sweeris via swift-users
> On Jul 9, 2017, at 10:06, David Baraff via swift-users > wrote: > > >> On Jul 9, 2017, at 8:27 AM, Jens Persson wrote: >> >> (Also, note that your implementation of == uses lhs === rhs thus will only >> return true when lhs and rhs are the same

Re: [swift-users] Filling two type parameters with the same type

2017-07-08 Thread David Sweeris via swift-users
You could try putting that init in an extension "where Source == Displacement" > On Jul 8, 2017, at 21:06, Taylor Swift via swift-users > wrote: > > I have a type like > > struct DistortedNoise where Source:Noise, > Displacement:Noise > { >

Re: [swift-users] Filling two type parameters with the same type

2017-07-08 Thread David Sweeris via swift-users
nt from my iPhone > On Jul 8, 2017, at 21:39, Zhao Xin <owe...@gmail.com> wrote: > > No, David, it is now allowed. "error: same-type requirement makes generic > parameters 'Source' and 'Displacement' equivalent". > > Zhao Xin > >> On Sun, Jul 9, 2017

Re: [swift-users] Filling two type parameters with the same type

2017-07-08 Thread David Sweeris via swift-users
thing. - Dave Sweeris > On Jul 8, 2017, at 9:39 PM, Zhao Xin <owe...@gmail.com> wrote: > > No, David, it is now allowed. "error: same-type requirement makes generic > parameters 'Source' and 'Displacement' equivalent". > > Zhao Xin > > On Sun, Jul 9,

Re: [swift-users] [swift-build-dev] SwiftPM manual dependency management

2017-07-22 Thread David Sweeris via swift-users
> On Jul 22, 2017, at 12:07, Geordie J wrote: > > >> Am 22.07.2017 um 19:46 schrieb David Sweeris : >> >> >> >> Sent from my iPhone >> >>> On Jul 22, 2017, at 05:16, Geordie Jay via swift-build-dev >>> wrote: >>> >>> How

Re: [swift-users] [swift-build-dev] SwiftPM manual dependency management

2017-07-22 Thread David Sweeris via swift-users
> On Jul 22, 2017, at 16:09, David Sweeris via swift-build-dev > wrote: > > Within the past day or so, someone on evolution rezzed Ted's announcement > thread on the matter. Whoops, I was wrong, it's a new thread called "Setting expectations on when we move to

Re: [swift-users] Can I use a tuple to force a certain memory layout?

2017-07-19 Thread David Sweeris via swift-users
> On Jul 19, 2017, at 20:33, Taylor Swift via swift-users > wrote: > > Many APIs like OpenGL take arrays where the atomic unit is multiple elements > long. For example, a buffer of coordinates laid out like > > :[Float] = [ x1, y1, z1, x2, y2, z2, ... , xn, yn, zn ] >

Re: [swift-users] Can I use a tuple to force a certain memory layout?

2017-07-21 Thread David Sweeris via swift-users
> On Jul 21, 2017, at 07:55, Johannes Weiß via swift-users > wrote: > >> On 21 Jul 2017, at 1:45 am, Taylor Swift wrote: >> >> Okay, apparently layout is only guaranteed if the reference is to the tuple >> itself, not a member of the tuple. Don’t

Re: [swift-users] How to reference a generic function when a concrete version also exists?

2017-05-02 Thread David Sweeris via swift-users
> On May 2, 2017, at 4:39 PM, Nevin Brackett-Rozinsky via swift-users > wrote: > > If I write a generic function like this: > > func f(_ x: T) { print("Generic: \(x)") } > > I can pass it to another function like this: > > func g(_ fn: (Int) -> Void) { fn(0) } > g(f)

Re: [swift-users] Can I create a Cocoa app that is only a Swift script?

2017-06-22 Thread David Sweeris via swift-users
> On Jun 22, 2017, at 02:55, tuuranton--- via swift-users > wrote: > > > It is not. The first problem is that there is no > > value of "/path/to/swift" that will work everywhere. > > > Makes sense, but I guess one day macOS will ship with swift in a standard >

Re: [swift-users] swift 4.0 complains/warns about swapping array elements

2017-05-19 Thread David Sweeris via swift-users
> On May 19, 2017, at 10:10, Edward Connell via swift-users > wrote: > > I just switched to the 5/17 swift 4.0 tool chain on Linux, and I am getting > the following complaint when using swap on array elements. Is this warning > legitimate because of a copy on write

Re: [swift-users] Intended behavior or bug in Dictionary's new subscript(_:default:)?

2017-06-18 Thread David Sweeris via swift-users
> On Jun 17, 2017, at 21:12, Ben Cohen via swift-users > wrote: > > In order for this defaulting subscript technique to work as intended, the > subscript { get } needs to be called, then the mutation happens, then the > subscript { set } writes the mutated value back,

Re: [swift-users] Any way to declare a method that suppresses the string interpolation warning?

2017-04-30 Thread David Sweeris via swift-users
> On Apr 23, 2017, at 23:23, Rick Mann via swift-users > wrote: > > >> On Apr 22, 2017, at 12:23 , Saagar Jha wrote: >> >> >> Saagar Jha >> >>> On Apr 21, 2017, at 04:35, Rick Mann via swift-users >>> wrote: >>> >>> I

Re: [swift-users] bigintegers

2017-09-19 Thread David Sweeris via swift-users
I don't know that there are any plans to implement big integers in the standard library. There's at least one open-source implementations, though: https://github.com/attaswift/BigInt Good luck with your class! :-) - Dave Sweeris > On Sep 19, 2017, at 8:12 PM, Muhammad Tahir Vali via

Re: [swift-users] Detect if a generic type is numeric

2017-10-05 Thread David Sweeris via swift-users
> On Oct 4, 2017, at 18:30, Kevin Lundberg via swift-users > wrote: > > Can you do something like this? > > func isNumber(_ value: T) -> Bool { return true } > > func isNumber(_ value: T) -> Bool { return false } > > I don't recall whether or not swift will pick the

Re: [swift-users] dealing with heterogenous lists/dictionary with Codable

2017-10-19 Thread David Sweeris via swift-users
Oh! Yeah, my bad... You are correct; I'd started thinking like I was on -evolution instead of -users. > On Oct 19, 2017, at 1:29 PM, Itai Ferber wrote: > > Mm, the point I’m trying to get at here is that JSON is inherently untyped > while Swift is strongly typed, and the

Re: [swift-users] dealing with heterogenous lists/dictionary with Codable

2017-10-19 Thread David Sweeris via swift-users
> On Oct 19, 2017, at 12:50 PM, David Baraff via swift-users > wrote: > > Yes; this is a case where anywhere in the code base I want to just say > struct MyNewType : Codable { > // add codable datatypes > } > > and don’t want/can’t always go to

Re: [swift-users] dealing with heterogenous lists/dictionary with Codable

2017-10-19 Thread David Sweeris via swift-users
I think if you can figure that out, you’re halfway to letting protocols conform to themselves. (Syntactically, I would probably say that something like “Codable.Self” would read well, but I think that already means something. Maybe the answer will become clearer when we rework the reflection

Re: [swift-users] FloatingPoint/BinaryFloatingPoint protocol and concrete FloatingPoint types

2017-12-03 Thread David Sweeris via swift-users
Sorry, mostly I was just commenting on what I now see was an incorrect interpretation of the “// but something actually requiring high precision ...” comment in your example code. I’d read it as... you know, I’m not sure what I’d though it said... I think something that implied the code would

Re: [swift-users] FloatingPoint/BinaryFloatingPoint protocol and concrete FloatingPoint types

2017-12-01 Thread David Sweeris via swift-users
> On Dec 1, 2017, at 13:18, Jens Persson via swift-users > wrote: > > func maxPrecisionCalculation(input:Float80) -> Float80 { > return input // but something actually reauiring high precision ... > } AFAIK, Float80 is the high precision format on macOS (well,

Re: [swift-users] Justification for Swift Design Decisions?

2017-10-31 Thread David Sweeris via swift-users
Specifically WRT to double quotes for characters, the Commonly Rejected Changes doc (https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md) says, "Swift takes the approach of highly valuing Unicode. However, there are multiple concepts of a character that could make sense in

Re: [swift-users] Re-initializing lazy vars

2017-10-19 Thread David Sweeris via swift-users
I don't know. IIRC (big if), though, there was talk of adding support for "property behaviors"(?). Resetting lazy vars probably would've been one of them, and if so, it probably got pulled so that we wouldn't risk breaking source compatibility later by adding a consistent syntax for other