|
Suspicious Dish posted:Do you imagine this being used in production, or is it a research language? The WWDC presentation certainly suggested to me that it's intended to replace Objective C entirely in a relatively prompt timeframe.
|
# ¿ Jun 2, 2014 19:58 |
|
|
# ¿ Apr 29, 2024 02:30 |
|
https://itunes.apple.com/gb/book/swift-programming-language/id881256329 is the book mentioned in the announcement.
|
# ¿ Jun 2, 2014 20:05 |
|
How do generics handle min(5, 5.1)? Mandatory casting to make the type inferrable?
|
# ¿ Jun 2, 2014 20:28 |
|
I ported a few smallish classes from Obj-C to Swift to get a feel for it, and so far I'm a fan. The interop is pretty painless (the biggest issue I've encountered is that NSXMLDocument(contentsOfURL: self.baseURL, options: NSXMLNodeOptionsNone, error: &error) doesn't compile (because the constant's CUnsignedInt and it's expecting Int?)), and even just a dumb mechanical translation is a surprising improvement. Way less boilerplate everywhere even while keeping obj-c style naming thanks to type inference and no more initWith, no loving headers, and a lot of little annoyances like having to declare every single property as nonatomic are gone.
|
# ¿ Jun 3, 2014 01:01 |
|
On the Xcode side of things it'd be nice if the warning about it inferring AnyObject suggested adding a cast rather than explicitly annotating as AnyObject, especially for for-int loops since it wasn't totally obvious I could just cast NSArray to Foo[] in the loop header.
|
# ¿ Jun 3, 2014 01:25 |
|
tef posted:- You have string interpolation, but no string formatting (yet?) String(format: "stuff %02X", 5) works fine. The documentation of the standard library current only mentions things different from obj-c (and not even all of that).
|
# ¿ Jun 3, 2014 02:23 |
|
tef posted:- Do you normalize unicode identifiers? Nope!
|
# ¿ Jun 3, 2014 02:33 |
|
rjmccall posted:I think we discussed it and decided that not normalizing was the right thing to do. IIRC, the problem is that locale-insensitive normalization is often not good enough, but making the compiler locale-sensitive would be a terrible idea.
|
# ¿ Jun 3, 2014 03:01 |
|
rjmccall posted:That doesn't actually scale to two closures on the same object. Ultimately, this is just asking for cycle detection. libextobjc's @weakify/@strongify is the least-bad solution I've seen in obj-c, and it's pretty bad.
|
# ¿ Jun 3, 2014 03:09 |
|
rjmccall posted:My Unicode is not very strong. I understand that there are normalizations you can do which would unify some strings, and we should probably at least be doing those. The question is whether (case-sensitive) string equivalence is actually locale-insensitive, because that's what I would expect name lookup to use in a maximally Unicode-aware world.
|
# ¿ Jun 3, 2014 03:39 |
|
At the moment trying to learn Swift without knowing Objective-C is probably not going to end well, but long term it seems perfectly reasonable to learn it without knowing C or Objective-C first, although you'll probably end up needing to know all three to write anything substantial.
|
# ¿ Jun 3, 2014 14:54 |
|
lord funk posted:I disagree. I think if your goal is to learn Swift you aren't going to get much benefit from trudging through ObjC. Plus the pedagogical advantage of learning in the Playground environment is fantastic.
|
# ¿ Jun 3, 2014 15:12 |
|
set.allObjects as Foo[]
|
# ¿ Jun 4, 2014 21:28 |
|
I don't get why you're trying to call readabilityHandler with a closure. Do you mean code:
|
# ¿ Jun 5, 2014 19:50 |
|
I'm guessing it's from ML where let x = 5 in ...stuff with x... is how variables are declared.
|
# ¿ Jun 5, 2014 19:56 |
|
Advanced Swift video is up. Was this the first time that Dave Abrahams' involvement was revealed? There was a lot of speculation about what project Apple had to offer that was interesting enough for him to shut down BoostPro, and I suppose that the chance to work on making generic programming possible in a language while avoiding the problems C++ ran into could certainly qualify.
|
# ¿ Jun 6, 2014 05:21 |
|
Meat Street posted:rjmccall: I saw that Chris retweeted someone talking about the -Otime flag to disable runtime safety checks. I have to assume this wasn't a general endorsement of using that flag, right? Am I missing something here? Unless your code is basically a series of proofs a la Haskell, I don't know why you'd want to opt out of that.
|
# ¿ Jun 6, 2014 23:41 |
|
I'm not sure if the Xcode UI actually exposes it, but optimizer flags are in general per-file.
|
# ¿ Jun 7, 2014 00:32 |
|
I can't stand actually editing anything in AppCode, but I still use it fairly regularly just for the refactoring tools. I'd prefer something integrated into Xcode, but the tools are totally worth the minor hassle.
|
# ¿ Jun 7, 2014 02:49 |
|
Dessert Rose posted:Am I supposed to be able to modify enum values if I pattern-match them?
|
# ¿ Jun 8, 2014 04:44 |
|
Common themes in #swift-lang: How do I get the length of a string? Why isn't Swift perfect? Four years is far longer than Apple should need to create a programming language. Why does Swift make it so hard to just use AnyObject everywhere? Swift is just like Objective C + X, where X is a language that has very little in common with Swift. I want to learn Swift but I don't own any Apple products.
|
# ¿ Jun 10, 2014 18:54 |
|
ultramiraculous posted:Woah what. Why is it not thread safe in both cases? It seems like either situation is a place where you'd do a dispatch_once if you were doing it yourself. dispatch_once_t has to be static (dispatch_once does clever things to avoid the need for synchronization that aren't guaranteed to work if the memory address was ever non-zero), so dispatch_once doesn't really work for member variables.
|
# ¿ Jun 18, 2014 15:09 |
|
How would reading from stdin work with the whole continuous evaluation thing? If it just reads one time then it's pointless, and if it reads every time the expression is evaluated it'd be unusable.
|
# ¿ Jun 20, 2014 22:20 |
|
code:
|
# ¿ Jun 28, 2014 01:34 |
|
NSNumber uses tagged pointers now, so NSNumber(int:2) doesn't create an NSNumber object and referential equality on NSNumbers isn't a meaningful operation.
|
# ¿ Jul 2, 2014 23:59 |
|
Axiem posted:If I must have one AppDelegate, is there a way that I can pass in a value from the build configuration to that AppDelegate, so that I can at least choose which View Controller to load?
|
# ¿ Jul 3, 2014 03:37 |
|
It's parsed as let result = (response.toInt() && result > 0), not (let result = response.toInt()) && result > 0
|
# ¿ Jul 4, 2014 15:06 |
|
You can pass the explicit types as a regular parameter:code:
|
# ¿ Jul 8, 2014 16:18 |
|
What would Closure even be? An empty protocol? To be able to call it you'd need to know the function's signature, and there's only one type for each signature.
|
# ¿ Jul 15, 2014 05:20 |
|
Axiem posted:I have noticed that there is also a DebugPrintable protocol, though I haven't entirely figured out where it decides which protocol to use. And it doesn't appear to me as though say, XCTAssert* functions use either of them, either.
|
# ¿ Jul 21, 2014 01:10 |
|
Beta 4's out with some awesome changes. I'm very happy about internal being the default access modifier and private being private to the implementation file rather than class. I'm also very happy to see String trying to actually do the right thing by default with unicode and CGFloat being less awful.
|
# ¿ Jul 21, 2014 18:19 |
|
I'm not sure if .HasValue even makes all that much sense. I can't think of any situations where you'd want to check if an optional has a value but not do anything with that value if it exists that aren't insane or dumb. I don't find the optional bool scenario all that confusing, but I definitely don't think that if x { ... x! ... } is something that the language should be encouraging when it has a much better construct for that.
|
# ¿ Jul 23, 2014 20:19 |
|
if x? { ... } would be a cute way to do explicit optional -> boolean conversions.
|
# ¿ Jul 23, 2014 21:36 |
|
It would have been nice to know a few months ago that iTunes was going to be rejecting Swift libraries targeting iOS 7.
|
# ¿ Sep 13, 2014 23:59 |
|
The error message when submitting is just "Invalid Info.plist value. The value for the key 'MinimumOSVersion' in bundle {framework name} is invalid. The minimum value is 8.0" and it happens only if the framework contains any Swift code. Maybe just a miscommunication somewhere about what was supported? Sideloading the ipa to an iOS 7 device works fine.
|
# ¿ Sep 14, 2014 04:29 |
|
Using CocoaPods from Swift isn't any more of an issue than any other Obj-C code. The main problematic bit is that all of the Swift files have to be in the final application target (both because CocoaPods can't create framework targets yet and because iOS 7 doesn't support Swift frameworks). The best solution I've come up with for that is to add the Swift source files to preserve_paths in the podspec and tell people to manually add the files to their application target after installing the pod (and prefixing names and not using internal access since your code isn't being built into its own framework).
|
# ¿ Oct 1, 2014 15:47 |
|
My general rule of thumb is that if it would be reasonable, sensible and possible to chain another method call after the method taking a closure, it shouldn't use the trailing closure syntax even if there happens not to be another call after it; otherwise it probably should. This is slightly more broad than statementy things.
|
# ¿ Jan 20, 2015 05:07 |
|
Just write correct code the first time.
|
# ¿ Feb 5, 2015 17:07 |
|
Requiring 10.10 makes me sad
|
# ¿ Feb 10, 2015 05:05 |
|
|
# ¿ Apr 29, 2024 02:30 |
|
Shortly after Swift was first announced I had a very dumb argument with a person who was convinced that the Swift compiler would be both faster and more reliable if they'd written just enough of it in C++ to bootstrap and then wrote the real thing in Swift.
|
# ¿ Feb 26, 2015 21:35 |