Re: [swift-users] Subtract a set of a subclass?

2016-09-01 Thread Zhao Xin via swift-users
No. I don't think what you so called principle should be applied here. For example, I have a `class Fruit`, then I have a `class Apple:Fruit`. If they are using different `hashValue` generating method, you suggest me to use composition instead of inheritance? Also, it is very common for subclass t

Re: [swift-users] Subtract a set of a subclass?

2016-09-01 Thread Jordan Rose via swift-users
The Liskov substitution principle says that a B should always be able to be treated like an A. Your Set may already contain Bs, even without them ever being statically typed as B. If you think A and B are unrelated types, you should

Re: [swift-users] Subtract a set of a subclass?

2016-09-01 Thread Zhao Xin via swift-users
I believe if B inherits A, they are not the same type. So the rule doesn't apply here. Zhaoxin On Fri, Sep 2, 2016 at 7:02 AM, Nick Brook wrote: > Hi Jordan, > > Thanks for the advice. > > What if a subclass does implement hashValue differently? It seems you are > saying a subclass should never

Re: [swift-users] Subtract a set of a subclass?

2016-09-01 Thread Zhao Xin via swift-users
> > `A hash value, provided by a type’s hashValue property, is an integer > that is the same for any two instances that compare equally. That is, for > two instances a > ​​ > and b of the same type` So do you believe A and B are the same type if B inherits A. That's the differences between you an

Re: [swift-users] Function to unsafe pointer and back

2016-09-01 Thread Andrew Trick via swift-users
> On Sep 1, 2016, at 12:37 PM, Lou Zell via swift-users > wrote: > > As to your real question, what’s your high-level goal? Swift doesn’t really > do pointers to functions [1] but it does provide lots of other excellent > ‘treat code as data’ features. If you can explain more about your goa

Re: [swift-users] Weak references in generic types

2016-09-01 Thread Howard Lovatt via swift-users
@Karl, You say "In the second example, you’re creating WeakReference. P does not conform to P or to AnyObject.", but P does conform to AnyObject. I suspect it is a compiler limitation/ bug. -- Howard. On Thursday, 1 September 2016, Karl wrote: > > On 1 Sep 2016, at 03:23, Howard Lovatt via s

Re: [swift-users] Subtract a set of a subclass?

2016-09-01 Thread Nick Brook via swift-users
Hi Jordan, Thanks for the advice. What if a subclass does implement hashValue differently? It seems you are saying a subclass should never override hashValue? Should Set not compare elements with == instead of hashValue? Thanks Nick M: +44 (0)7986 048 141 W: http://nickbrook.me

Re: [swift-users] Subtract a set of a subclass?

2016-09-01 Thread Jordan Rose via swift-users
> On Sep 1, 2016, at 15:44, Zhao Xin via swift-users > wrote: > > Hi Nick, > > Glad to help. > > but when using third party classes I don’t know if the hash values are > comparable > > You can create an extension with a convenient init(:), which creates a new > instance of the super class

Re: [swift-users] Subtract a set of a subclass?

2016-09-01 Thread Zhao Xin via swift-users
Hi Nick, Glad to help. but when using third party classes I don’t know if the hash values are > comparable > You can create an extension with a convenient init(:), which creates a new instance of the super class basing on the instance of the sub class. That will guarantee the subtraction. Below

Re: [swift-users] DWARF without DSYM

2016-09-01 Thread Dmitry Shevchenko via swift-users
Hi all, thanks for all the pointers. After some more research, I have found that without dSYM, Xcode uses -add_ast_path to encode swiftmodule location. It then seems like you can only have one AST tag per binary, or at least only the first one is checked - https://github.com/apple/swift-lldb/blob

Re: [swift-users] Statically linked binaries on linux

2016-09-01 Thread Daniel Dunbar via swift-users
We don't currently build static versions of the other libraries (Foundation, XCTest), or a support process for picking them up. This is covered by: https://bugs.swift.org/browse/SR-648 As you note, it largely works for Swift-only, so this is feasible but we need someone to drive it. Are you i

Re: [swift-users] Function to unsafe pointer and back

2016-09-01 Thread Lou Zell via swift-users
> > As to your real question, what’s your high-level goal? Swift doesn’t > really do pointers to functions [1] but it does provide lots of other > excellent ‘treat code as data’ features. If you can explain more about > your goal, perhaps we can direct you to a better path. > ​ Curiosity got the

[swift-users] Statically linked binaries on linux

2016-09-01 Thread Joel Hughes via swift-users
Hi, I'm attempting to get a statically linked binary and am running into errors. I'm using Swift 3 Preview 6 on Ubuntu. Regular _swift build_ and _swift test_ are all running fine. I can produce a static binary for a simple "hello world" using: swift build -c release -Xswiftc -static-stdlib (

Re: [swift-users] Subtract a set of a subclass?

2016-09-01 Thread Nick Brook via swift-users
Hi Zhao Thanks for your response. I understand your point, but when using third party classes I don’t know if the hash values are comparable, but for example I may want to have a set of ‘data' (NSData) and a subset of ‘mutable data' (NSMutableData), which point to the same objects. As a user o

Re: [swift-users] forEach error: Parameters may not have the 'var' specifier

2016-09-01 Thread Zhao Xin via swift-users
You issue is more like func foo(var bar:Int) { // error: Parameters may not have the 'var' specifier } So yes, `var` is not allow any more. Removing var from Function Parameters (SE-0003)

[swift-users] forEach error: Parameters may not have the 'var' specifier

2016-09-01 Thread CK TUNG via swift-users
This error is for Swift 3 Xcode 8 beta 6 array.forEach {( var a : AnyObject) -> () in // error here : Parameters may not have the 'var' specifier    // modify object here } for var a in array {  // OK     // modify object here } ___ swift-users maili

[swift-users] Swift Strangeness? Failable initializer overriding non-failable vs. default parameters

2016-09-01 Thread Stefan via swift-users
Hi all, recently I stumbled upon an interesting and slightly confusing aspect of our favorite language. I had defined a Cache class to conform to NSCoding and inherit from NSObject. My class’s initializer was declared init?(entries: [Entry]? = nil) at first, giving an option to pre-populate i

Re: [swift-users] Function to unsafe pointer and back

2016-09-01 Thread Quinn "The Eskimo!" via swift-users
On 1 Sep 2016, at 01:41, Lou Zell via swift-users wrote: > 3. What is a reabstraction thunk helper (do I want to know :)) This makes for a great read. As to your real question, what’s your high-level go

Re: [swift-users] How to extend a generic type with a Bool constraint?

2016-09-01 Thread Quinn "The Eskimo!" via swift-users
On 31 Aug 2016, at 19:09, Jens Alfke via swift-users wrote: > (Any doc writers listening? Or is there a procedure for requesting > improvements to the book?) If you file a Radar bug against the doc it will go to the right folks [1]. > I’m also be

[swift-users] [swift-corelibs-foundation] Tests not showing in Xcode test navigator

2016-09-01 Thread Dan Tugendraich via swift-users
I have performed all the getting started steps in; https://github.com/apple/swift-corelibs-foundation/blob/swift-3.0-branch/Docs/GettingStarted.md Everything seems to be working fine, I can build the SwiftFoundation target and I can run the TestFoundation target. But one of the tests are failing