Re: [swift-users] String initializers and developer ergonomics

2016-05-10 Thread Karl Wagner via swift-users
Now that I see it, I realise I’ve run in to that a fair few times myself; I didn’t even know the string-view initialisers were failable. I’m not sure I understand why reflection is exposed as an initialiser on String in the first place - it might make more sense as a global function. Karl > On

Re: [swift-users] Cross-Compiling For ARM Linux

2016-05-12 Thread Karl Wagner via swift-users
> On 11 May 2016, at 20:41, Donald Pinckney via swift-users > wrote: > > Hi all, > Perhaps this has been discussed a lot already, but I'm a bit lost as to the > current state of cross-compiling Swift source code from x86_64 Linux to ARM > Linux. Given the documentation for cross-compiling fo

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

2016-09-08 Thread Karl Wagner via swift-users
What I'm trying to say is that P is a protocol and not a class, so it does not conform to AnyObject. P does not conform to P. It is in some sense a language limitation that we cant express what you're talking about. If we weren't using mailing lists it would be easier to search fo

Re: [swift-users] Existentials in Swift

2016-11-21 Thread Karl Wagner via swift-users
1. Yes 2. Yes 3. I don't know the actual reason, but Any and AnyObject have special meaning to the compiler and objects implicitly "conform"" to them. Either the implementation doesn't support extending those types, or we explicitly decided that extending these implicit existentials was

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

2017-02-09 Thread Karl Wagner via swift-users
Happy dance! 🎉🕺🎉 I've said before that I think this a good move. Hopefully it encourages more ad-hoc contributions - e.g. Unicode experts who have suggestions for the String model, Perl developers with suggestions for pattern-matching, systems architects with suggestions f

Re: [swift-users] So how do you implement a NSTextStorage subclass in Swift?

2017-02-12 Thread Karl Wagner via swift-users
I've seen this before; I considered it something to be resolved in AppKit. Strings in Swift are values, and the framework expects it to be a reference. Since NSTextStorage is itself a reference-type and informs its delegate of changes, those frameworks should probably retain the NSTS itsel

Re: [swift-users] Associatedtype Naming Conventions

2017-06-06 Thread Karl Wagner via swift-users
> On 7. Jun 2017, at 00:25, Dave Abrahams via swift-users > wrote: > > > on Wed May 31 2017, Steven Brunwasser > wrote: > >> Yes, I understand this. I was just wondering if there was a naming >> convention I should use to differentiate them. > > I would try

Re: [swift-users] Swift 4 protocol with associatedtype conforming to itself

2017-06-07 Thread Karl Wagner via swift-users
> On 7. Jun 2017, at 11:29, Jens Persson via swift-users > wrote: > > I see, this quote from the introduction of SE-0142 is not to be taken > literally then: > > For example, the SequenceType protocol could be declared as follows if the > current proposal was accepted: > > protocol Sequence

Re: [swift-users] A protocol-oriented numerics library

2017-06-10 Thread Karl Wagner via swift-users
> On 10. Jun 2017, at 03:18, Xiaodi Wu via swift-users > wrote: > > Hi all, > > A few weeks ago, Joe Groff challenged users on Twitter to create a > Rational type making use of the new integer protocols implemented for > Swift 4. As it happens, I'd already started a project to try out these

Re: [swift-users] How to write a test against fixture resources from generated xcodeproj test bundle?

2017-06-13 Thread Karl Wagner via swift-users
> On 10. Jun 2017, at 04:02, Toshihiro Suzuki via swift-users > wrote: > > Hi Swift Community, > I'm Toshihiro Suzuki and have a question about Swift Package Manager. > I'm trying out with new Xcode9-beta. > > When I generate a new xcodeproj like this, `Resources` directory is imported > as a

Re: [swift-users] Restricting associated values

2017-06-19 Thread Karl Wagner via swift-users
> On 19. Jun 2017, at 20:03, Karl Wagner wrote: > > >> On 19. Jun 2017, at 04:30, Nevin Brackett-Rozinsky via swift-users >> mailto:swift-users@swift.org>> wrote: >> >> Is there a way to restrict the associated values of an enum? For example, >> suppose I have this type: >> >> enum Angle {

Re: [swift-users] Restricting associated values

2017-06-19 Thread Karl Wagner via swift-users
> On 19. Jun 2017, at 04:30, Nevin Brackett-Rozinsky via swift-users > wrote: > > Is there a way to restrict the associated values of an enum? For example, > suppose I have this type: > > enum Angle { > case radians(Double) > case degrees(Double) > } > > I want to ensure that the rad

Re: [swift-users] Protocol Conformance

2017-06-19 Thread Karl Wagner via swift-users
> On 20. Jun 2017, at 01:38, Muhammad Tahir Vali via swift-users > wrote: > > Hey all, > > I wanted to know if theres a work around for a problem I am having > > lets say I have a protocol > > protocol Graphable : CustomStringConvertible, Sequence, Collection { > var vertices : [AnyVert

Re: [swift-users] Start another program from Swift script

2018-01-04 Thread Karl Wagner via swift-users
These kinds of things live in Foundation, not the standard library: import Foundation let p = Process() p.executableURL = URL(fileURLWithPath: "/bin/ps") try p.run() The Process class provides you with stdin/out/error handles for the process (https://developer.apple.com/documentation/foundation

Re: [swift-users] KeyPaths and PartialKeyPaths - when can you leave out the class?

2018-01-16 Thread Karl Wagner via swift-users
+1 An example I ran in to today: func dumpKeys(of object: T, _ keypaths: PartialKeyPath...) { for kp in keypaths { print("-", "\(kp): \(object[keyPath: kp])") } } Then in LLDB, I want to be able to write: dumpKeys(of: context, \.invalidateEverything, \.invalidateDataSourceCounts) But t