|
I strongly suspect I know the answer to this, but: Does XCode 6.3 carry along any sort of compatibility mode for previous versions of the language? I'd like to bisect a Swift project, but the old code doesn't build with 6.3 and I really don't want to have to juggle XCode versions to make progress.
|
# ? Apr 21, 2015 18:56 |
|
|
# ? May 14, 2024 10:37 |
|
Subjunctive posted:I strongly suspect I know the answer to this, but: I believe there's an older compiler built into the migration tool, but I doubt you can use it to actually compile something. So nope.
|
# ? Apr 21, 2015 22:15 |
|
Is there a way to force the compiler to capture a local as a mutable reference or do we just manually box it?
|
# ? Apr 22, 2015 20:01 |
|
Ender.uNF posted:Is there a way to force the compiler to capture a local as a mutable reference or do we just manually box it? Swift will always capture a local var as a mutable reference, up to the limits of as-if.
|
# ? Apr 22, 2015 21:42 |
|
rjmccall posted:Swift will always capture a local var as a mutable reference, up to the limits of as-if. Not always. rdar://20657776 filed with attached working test case as a playground. code:
|
# ? Apr 22, 2015 22:28 |
|
So I'm having a weird issue where I'm trying to make a whiteboard app and the code works fine on a workmates phone and on the simulators on his laptop but then as soon as I ty it any line I draw is skewed and moved up almost as if it's getting pushed onto the z axis. This is just code we're using from a Ray Wanderlich tutorial. code:
|
# ? Apr 23, 2015 16:51 |
|
Getting tons of segmentation fault: 11 errors with any action besides Run in Xcode 6.3.1 in our Swift solution. Anyone else running into this? Googling brings up other issues as well.
|
# ? Apr 24, 2015 16:18 |
|
Ender.uNF posted:swiftc is written in C++... is there any reason that it doesn't catch exceptions and bail on processing a section of code (or a file) if it blows up? I think here you're conflating two different kinds of exceptions: language-level exceptions, and OS/system-level exceptions (traps, signals, whatever you'd like to call them). You can use signal() handlers and Mach exception handlers to try to capture OS-level exceptions, but your recovery options are limited except for very specialized software (like debuggers). Language-level exceptions tend to be designed for recoverability, though in practice most such exceptions should also wind up aborting the process because most software isn't itself designed for recovery.
|
# ? Apr 25, 2015 22:43 |
|
eschaton posted:I think here you're conflating two different kinds of exceptions: language-level exceptions, and OS/system-level exceptions (traps, signals, whatever you'd like to call them). I'm not conflating anything but I don't think I'm communicating what I'm asking for very well. I've been staying up until 3am every night working on my watch app.
|
# ? Apr 25, 2015 23:26 |
|
Possibly stupid swift noob question - how come I can do code:
but I can't do code:
|
# ? Apr 29, 2015 09:39 |
|
Try map(someString) { ... }
|
# ? Apr 29, 2015 12:20 |
|
What's the deal with CKRecord and subscripting from Swift? It works in ObjC because it implements the magic setObject:forKey: method, but Swift doesn't know about that. However, when I try to define it in a Swift extension, I get a compiler error because it's trying to define the magic method for me, but it already exists. So I'm stuck calling setObject() from my Swift code. Which makes me sad.
|
# ? Apr 30, 2015 05:32 |
|
If the problem is a conflict on the Objective-C side then you could usually work around it by giving it a different name there, using @objc(…). I suspect that doesn't work for subscripts though, but I haven't tried it. The other workaround is to use some Swift feature that can't be exported to Objective-C, such as generics, but it would take some fiddling to find out if that is viable.
|
# ? Apr 30, 2015 05:47 |
|
pokeyman posted:Try map(someString) { ... } I get that you can do that, it just seems odd to me that you can do all these 'treat a string as an array of characters' operations, but the standard map-reduce syntax doesn't work, and was wondering what the reasons behind that are.
|
# ? Apr 30, 2015 12:04 |
|
*edit* Nevermind, I'm dumb and can't read.
|
# ? Apr 30, 2015 16:10 |
|
Map is available on strings because they're sequences. For whatever reason you just can't do extensions on sequences, but you can do regular old functions for sequences. I think this relates to type constraints not being available on extensions. They actually bothered to make map a method on Array but not on certain other types.
|
# ? Apr 30, 2015 16:20 |
|
Yeah that explains it, plus I was really confused...I assumed map() and reduce() where extensions on SequenceType/GeneratorType, rather than just being methods of Array(). Is there any chance of having extensions on protocols in the future?
|
# ? May 1, 2015 10:24 |
|
Pretty good odds, I'd say, and sooner rather than later. The standard library people have wanted that for ages.
|
# ? May 1, 2015 18:18 |
|
fleshweasel posted:Map is available on strings because they're sequences. For whatever reason you just can't do extensions on sequences, but you can do regular old functions for sequences. I think this relates to type constraints not being available on extensions. They actually bothered to make map a method on Array but not on certain other types. A million times this... I repeatedly find myself wanting to define an extension on some type but only when it satisfies certain generic constraints. It seems like a small thing but it just makes the coding process so much more intuitive when the methods pop up in autocomplete because they're defined explicitly for the type you're working with. Anyone else have Swift frameworks they've been loving? PromiseKit (despite its slightly rough shape) and Cartography have been wonderful and fairly good demonstrations of how much cleaner and nicer it can be to go 100% Swift.
|
# ? May 1, 2015 18:24 |
|
I'm trying to write a lovely stack based language in Swift, and its been great fun so far...are abstract classes/methods planned for Swift at all? What about implicit return values?
|
# ? May 3, 2015 14:37 |
|
We've thought about abstract classes/methods, but haven't yet designed them. Is there something you can't do with a class-constrained protocol? We don't have plans for implicit return values, but I'm curious to know what you're thinking of using them for.
|
# ? May 3, 2015 20:50 |
|
Hey rjmccall, We're getting segmentation faults during compilation on a select few view controllers. All of them inherit from a base subclassed UITableViewController. This crashes in any configuration where "Swift Compiler Code Generation - Optimization level is set to anything above [None]. We no longer get the segmentation faults after having removed any of the optimization levels. Have you seen this before? Doh004 fucked around with this message at 23:08 on May 5, 2015 |
# ? May 5, 2015 22:43 |
|
rjmccall posted:We've thought about abstract classes/methods, but haven't yet designed them. Is there something you can't do with a class-constrained protocol? quote:We don't have plans for implicit return values, but I'm curious to know what you're thinking of using them for.
|
# ? May 6, 2015 09:31 |
|
This code seems to an exception in the compiler when run at SwiftStub, with "expression was too complex to be solved in reasonable time"code:
|
# ? May 7, 2015 11:03 |
|
toiletbrush posted:This code seems to an exception in the compiler when run at SwiftStub, with "expression was too complex to be solved in reasonable time" It's always worth filing a radar for things like this.
|
# ? May 7, 2015 19:14 |
|
I think there are two reasons I post my issues here first. One is that I'm not even sure if what I'm writing is valid Swift in the first place, and I don't want to spend the time writing up a bug about it. Two is that writing up a bug is going to kill my productivity for the next hour as I reduce it into a test case and put it into a project, write up the repro steps properly, etc. Compared to "just paste some code and rjmccall will call me an idiot or tell me to file a radar", it's pretty obvious which one I'm going to do first.
|
# ? May 8, 2015 00:49 |
|
Well. You are welcome to continue to use me for first-level bug triage, if the alternative is just not filing the radar. That said, if you can get a test case down to the point where "xcrun swift myfile.swift" produces something obviously wrong — it emits a bad diagnostic or crashes in the compiler or crashes running the program or generates meaningless output — you really don't need anything else in the radar besides the file, the command line, and a copy/paste of the bad output. I hope there isn't some weird process preventing that. "Expression too complex" radars in particular are almost always good to file, because while our type-checker is kindof inherently algorithmically inefficient, most of those problems are not really limited by that inherent complexity, and there's usually some way we could be solving the constraint system much more efficiently. In toiletbrush's example, the type-checker has probably decided to try to solve the part of the system that's within the closure before deducing that $0 : Int, and so the complexity is blowing up. (Why are you writing that with map instead of "for i in 0...10 {", anyway?)
|
# ? May 8, 2015 03:46 |
|
rjmccall posted:In toiletbrush's example, the type-checker has probably decided to try to solve the part of the system that's within the closure before deducing that $0 : Int, and so the complexity is blowing up. code:
quote:(Why are you writing that with map instead of "for i in 0...10 {", anyway?)
|
# ? May 8, 2015 12:31 |
|
toiletbrush posted:Does that explain why this... Yeah. The type-checker proceeds by considering an entire expression at once, since in theory any part of it can affect any other part. Of course, it can usually retire/simplify constraints immediately, break things into subproblems, etc. But if it can't finish type-checking, it can't finish type-checking, and that means it can't decide whether the code should compile or not. If anyone's really curious, our type system is basically System F<, which we try to reconstruct with a custom constraint solver. The way this works in practice is that Swift basically assigns a "type variable" to every expression, like so: pre:0 : T0 10 : T1 ... : T2 0...10 : T3 [Int](0...10) : T4 [Int](0...10).map : T5 etc. pre:T2 = (T6, T7) -> T3 // from binary operator syntax T2 in { <all the overloaded ... types> } // the result of operator lookup (T0, T1) < (T6, T7) // call argument conversion [Int] hasMember "init" : T8 // from initialization syntax; will turn into an "in" constraint like the above T8 = T9 -> T4 // initialization syntax calls the init method T3 < T9 // call argument conversion T4 hasMember "map" : T5 // from member reference syntax etc.
|
# ? May 9, 2015 00:18 |
|
I'm playing around with generating Swift programmatically. In C/Objc-C/etc you can put #line 95 "file.ext" to make errors & such point to the correct line in the input file that the Swift is generated from. I guess I can't do that in Swift?
|
# ? May 11, 2015 20:57 |
|
Snapchat A Titty posted:I'm playing around with generating Swift programmatically. In C/Objc-C/etc you can put #line 95 "file.ext" to make errors & such point to the correct line in the input file that the Swift is generated from. I guess I can't do that in Swift? Uh, no, not right now, sorry.
|
# ? May 11, 2015 21:34 |
|
Alright, thanks
|
# ? May 11, 2015 21:46 |
|
rjmccall posted:if you can get a test case down to the point where "xcrun swift myfile.swift" produces something obviously wrong — it emits a bad diagnostic or crashes in the compiler or crashes running the program or generates meaningless output — you really don't need anything else in the radar besides the file, the command line, and a copy/paste of the bad output. I hope there isn't some weird process preventing that. Ah, that's much better. I'd had a couple of bugs bounced because I included just a playground or not even that, and they said to submit an entire project. If the actual requirements are somewhere in the middle, then I'll submit more bugs, thanks
|
# ? May 11, 2015 21:49 |
|
Dessert Rose posted:Ah, that's much better. I'd had a couple of bugs bounced because I included just a playground or not even that, and they said to submit an entire project. If the actual requirements are somewhere in the middle, then I'll submit more bugs, thanks Well, like I said, the screeners might be jerks. But the team can certainly fix bugs based only on a single file and a command line, and that's how we file them internally.
|
# ? May 12, 2015 05:40 |
|
rjmccall posted:Well, like I said, the screeners might be jerks. But the team can certainly fix bugs based only on a single file and a command line, and that's how we file them internally.
|
# ? May 12, 2015 09:25 |
|
toiletbrush posted:I think I might have been reporting my bugs to the wrong place, what is the correct product for filing Swift bugs? There's a Swift component. I... actually don't know what bugreport.apple.com looks like for you, because it immediately forwards to an internal web version of the application for me; but I'm pretty sure you can just file against Swift. I would not file against Playgrounds unless it only duplicates in Playgrounds and/or is a problem with the Playgrounds user interface; and I wouldn't file it against Xcode in general unless it's obviously a UI or build-system problem (and the dividing lines for the latter are blurrier than you might expect). Dessert Rose, we do accept a lot of playgrounds as bug reports; maybe you just ran into someone feeling cantankerous, sorry. The only time we really need it as a project is when it's a multi-file compilation issue, which does come up a fair amount.
|
# ? May 12, 2015 21:45 |
|
rjmccall posted:There's a Swift component.
|
# ? May 12, 2015 21:53 |
|
toiletbrush posted:Oh, it doesn't show up for me...I'm a member of iOS and Mac developer programs, but in the Development section I only get iOS/SDK, OS X/SDK and a couple others but nothing for Swift specifically... Bah. I'm not sure where you're supposed to file these bugs, then, sorry. Probably Xcode.
|
# ? May 12, 2015 21:56 |
|
I file Swift bugs under Developer Tools.
|
# ? May 13, 2015 01:31 |
|
|
# ? May 14, 2024 10:37 |
|
How are you guys handling the optional protocol pattern in swift? I want to make it a rule that if you need this pattern in swift to not use @objc, but to use inheritance or composition of different protocols and optionals. But I'm getting push back because of what I think is a crufty reason. "It's a useful pattern and thats why apple gave us @objc" Outside of IBOutlets, and Vending to objc I want to remove as much @objc as possible.
|
# ? May 15, 2015 19:52 |