|
There was a thread on the dev forums a little while ago where an Apple engineer said they were aware that optional booleans are error-prone and they consider it a problem. So hopefully that'll get fixed before 1.0. I thought I'd mention this since I don't think a lot of people know about it yet: I was really happy to learn the other day that you can use the same name for the unwrapped value as the optional when using if let. So you can do if let value = value instead of having to come up with some arbitrary name for one or the other like if let v = value.
|
# ? Jul 23, 2014 21:23 |
|
|
# ? May 14, 2024 17:58 |
|
if x? { ... } would be a cute way to do explicit optional -> boolean conversions.
|
# ? Jul 23, 2014 21:36 |
|
ljw1004 posted:rjmcall Please remove this feature, and instead implement a method ".HasValue" on Optional<T>. That way we can write code that's easy to read: This is actually already in the works, although I'm not sure how we're going to spell the property yet. (Other than definitely not using C# casing.)
|
# ? Jul 23, 2014 22:36 |
|
rjmccall posted:This is actually already in the works, although I'm not sure how we're going to spell the property yet. (Other than definitely not using C# casing.) I'm a fan of Guava's Optional's .isPresent(), or alternatively .present() for brevity if that is desired.
|
# ? Jul 23, 2014 23:10 |
|
Ender.uNF posted:rdar://17782662 filed to add the ability to export a module's internal members to another specified module. This makes unit tests on internal members much easier and allows two modules by the same developer to cooperate as if they were the same module, but without making that part of the public API. Yes, this is 100% the most annoying thing about access modifiers right now. Right after getting the beta 4 and fixing the fact that Double no longer auto-converts to CGFloat, I tried running tests and ended up with an awful lot of failures because I need to sprinkle "public" everywhere.
|
# ? Jul 23, 2014 23:55 |
|
I HAVE A BUG TO REPORT!! The blogposts from the Swift Blog's RSS feed are almost wholly unformatted, and in this most recent blog post about Access Control, it completely omitted the example code and instead had "Here is an example class that is part of a framework: [view code in blog] ". In the xml source I can see there are some extra spaces where bullet points should be, but there's not even a newline before them (and of course the rendered output has all contiguous whitespace condensed anyway). I want to read the entire blogpost in my RSS reader, not a seeming copy-paste job that excludes example code! Here's the current RSS feed itself, for the curious: http://pastebin.com/KSjuf2jE I know that the workings of the Swift Blog's RSS feed are of utmost importance to you rjmccall, so uh, you're welcome I really enjoy reading about all this stuff and I haven't filed a bugreport in years and years -- should this actually be a radar?
|
# ? Jul 24, 2014 01:41 |
|
Axiem posted:Yes, this is 100% the most annoying thing about access modifiers right now. Right after getting the beta 4 and fixing the fact that Double no longer auto-converts to CGFloat, I tried running tests and ended up with an awful lot of failures because I need to sprinkle "public" everywhere. As an alternative to manually labeling everything as public, you can group your public API into an extension labeled as public, and everything inside that extension will default to public.
|
# ? Jul 24, 2014 01:57 |
|
dizzywhip posted:As an alternative to manually labeling everything as public, you can group your public API into an extension labeled as public, and everything inside that extension will default to public. In quite a few cases, this will end up being an extension of everything in the class. At the current state of the project, most of my things are either value objects or don't have much internal logic; they're all API.
|
# ? Jul 24, 2014 02:44 |
|
Abjad Soup posted:I HAVE A BUG TO REPORT!! Oh man. I'm sure it would get routed to the right people if you filed it as a radar. I have no idea who those people would be, though.
|
# ? Jul 24, 2014 05:50 |
|
This is the second time I've started writing this horrible abomination... if I don't get some real reflection soon I won't be able to stop myself from unleashing it upon the world. I am going to get the type's members and their type names one way or another. Also the unknowns are suspiciously in the executable region; brute forcing the function call didn't work but I found someone who figured out the function call trampoline and associated structs. When I get back from dinner that's my next horrible, horrible step. I'm going to put functions inside a dictionary and invoke them later if it kills me. code:
|
# ? Jul 25, 2014 01:00 |
|
Ender.uNF posted:P.S. I'm moving to the SF/Bay area soon, joining a startup and moving to iOS full time. Can I be part of the cool kids club now? Enjoy the huge rent. I thought I could escape it in San Jose (and did for a year!) but it eventually caught up down here too. Now there's no escaping it.
|
# ? Jul 25, 2014 01:03 |
|
Flobbster posted:Enjoy the huge rent. I thought I could escape it in San Jose (and did for a year!) but it eventually caught up down here too. Now there's no escaping it. Oh yes, it's crazy. I'm going to try to buy if possible. I just can't pay 3000-4000 a month for an apartment and end up with nothing for it. That said, I have no idea how difficult it is to get a mortgage out there and I hear stories of people coming in with all cash offers, so that's scary too. Simulated fucked around with this message at 01:51 on Jul 25, 2014 |
# ? Jul 25, 2014 01:46 |
|
Ender.uNF posted:Oh yes, it's crazy. I'm going to try to buy if possible. I just can't pay 3000-4000 a month for an apartment. Afaik you want to avoid buying because transfer of ownership means taxes get recalculated in California, so it might be more expensive in the end. Least that's what I heard, I've only rented there.
|
# ? Jul 25, 2014 01:50 |
|
What protocol do I need to implement on an object so that XCTAssertEqual will output what I want in its default text, instead of the mangled name of the class? I've tried Streamable, Printable, and DebugPrintable to no avail. I'm getting really tired of my tests failing with the eternally unhelpful message `XCTAssertEqual failed: ("_TtC11SpaceTrains4Star") is not equal to ("_TtC11SpaceTrains4Star")`. It would be nice to be able to at least identify which is which in the output, so I could better figure out why a test is failing, and I'd rather not go and add my own custom format to each assertion when the default one is otherwise quite fine.
|
# ? Jul 29, 2014 00:14 |
|
edit: I see what is happening here; those things are @auto_closures and the compiler is breaking down the AST (presumably) and doing other fancy strangeness so you can't actually do anything about it. Simulated fucked around with this message at 05:40 on Jul 29, 2014 |
# ? Jul 29, 2014 05:34 |
|
quote:operator infix !! { associativity left } Is there any reason this shouldn't work? The compiler complains that no overloads take the supplied arguments which is incorrect. In theory it should be using the first on x !! y, which produces an optional and so the second would be called with that result and z. If you move "alt" inline the compiler complains about converting a StaticString to String.
|
# ? Jul 29, 2014 07:01 |
|
It is probably failing to correctly order the auto-closure argument with the argument requiring an optional conversion.
|
# ? Jul 29, 2014 07:31 |
|
Ok, rdar://17842481 filed Edit: autocorrect Simulated fucked around with this message at 18:45 on Jul 29, 2014 |
# ? Jul 29, 2014 17:12 |
|
I did a horrible, horrible thingcode:
|
# ? Jul 30, 2014 04:21 |
|
Ender.uNF posted:
|
# ? Jul 30, 2014 07:32 |
|
Is this abomination rjmccall approved now or something?
|
# ? Jul 30, 2014 07:43 |
|
To be fair, I did try something like that but forgot I declared them "let" and the compiler just gave me another "cannot convert to @lvalue $T###" sort of message. I filed rdar://17857686 to ask that Swift output something like "Cannot pass 'let' constant reference to parameter expecting mutable 'inout'". I'm sure you already have a ton of bugs related to type conversion error messages since they're all pretty much like that in beta 4. So what I'm saying is I take no responsibility for my own failures and blame it all on you P.S. Is there any way to get the type names/descriptions that the REPL will spit out? (i.e. find out that i's type is Swift.Int) pre:Welcome to Swift! Type :help for assistance. 1> let i = 5 i: Int = 5 2> let mirror = reflect(i) mirror: _LeafMirror<Int> = { _value = 5 summaryFunction = quickLookFunction = } 3> mirror.valueType $R0: Any.Type = Swift.Int
|
# ? Jul 30, 2014 18:17 |
|
ultramiraculous posted:Is this abomination rjmccall approved now or something? You can do what you want, Abe.
|
# ? Jul 31, 2014 04:21 |
|
Have you done any benchmarking on Swift to see how it compares? Does it keep C/C++'s speed?
|
# ? Jul 31, 2014 06:01 |
|
Right now? Definitely not. And the overhead of automatic memory management will limit us from ever exactly matching C on all workloads. On the other hand, I think eventually we'll have a complete enough set of language/implementation tools to allow users to reliably optimize away overheads when it matters without massively distorting their program.
|
# ? Jul 31, 2014 06:54 |
|
rjmccall posted:Right now? Definitely not. And the overhead of automatic memory management will limit us from ever exactly matching C on all workloads. On the other hand, I think eventually we'll have a complete enough set of language/implementation tools to allow users to reliably optimize away overheads when it matters without massively distorting their program. Is this one of the reasons they're not rushing to rewrite Mail.app etc... in Swift?
|
# ? Jul 31, 2014 07:44 |
|
xilni posted:Is this one of the reasons they're not rushing to rewrite Mail.app etc... in Swift? Mail is a shipping app with time-tested code that already works.
|
# ? Jul 31, 2014 17:24 |
|
Swift is also still in beta and thats a pretty large codebase to rewrite in a language that could still have syntax and behavioural changes.
|
# ? Jul 31, 2014 19:33 |
|
rjmccall posted:Right now? Definitely not. And the overhead of automatic memory management will limit us from ever exactly matching C on all workloads. Makes sense; safety costs. Presumably as a statically compiled language with a decent optimisation backend you should end up coming pretty close, though?
|
# ? Jul 31, 2014 20:06 |
|
feedmegin posted:Makes sense; safety costs. Presumably as a statically compiled language with a decent optimisation backend you should end up coming pretty close, though? Yes, we don't see anything that should prevent us from generating very high-performance code on the approximate order of C.
|
# ? Jul 31, 2014 20:24 |
|
Something that I sometimes did in Objective-C was return or accept specific types that conform to specific protocols. Using Generics we can do this for function parameters (I think its analogous) but how do we enforce this on the return side? code:
code:
|
# ? Aug 2, 2014 16:15 |
|
Kallikrates posted:Something that I sometimes did in Objective-C was return or accept specific types that conform to specific protocols. Did you try func foo() -> (Foo) {}?
|
# ? Aug 3, 2014 02:57 |
|
Kallikrates posted:
Is there some reason you can't: code:
Also, is there a reason you're insisting it be an NSObject, instead of just an object that conforms to Foo?
|
# ? Aug 3, 2014 13:47 |
|
The example is derived..., the object implementing the protocol is not a plain NSObject. On the API consumer side, knowing its class X implements protocol Y is helpful when you want to call functions of class X and protocol Y without having to cast back and forth between "id<Foo>" and "X" when I get back to my computer with Xcode Beta ill try (protocol<NSObject, Foo>) but I don't think its a solution because the NSObject protocol only exists for base NSObject, not subclasses, Another example: code:
Another option would be to create a protocol of all the public methods/functions of a class and then use protocol composition, but that's not necessary in Obj-c so I don't think it should be needed in Swift. Kallikrates fucked around with this message at 18:56 on Aug 3, 2014 |
# ? Aug 3, 2014 18:52 |
|
Kallikrates posted:The example is derived..., the object implementing the protocol is not a plain NSObject. On the API consumer side, knowing its class X implements protocol Y is helpful when you want to call functions of class X and protocol Y without having to cast back and forth between "id<Foo>" and "X" when I get back to my computer with Xcode Beta ill try (protocol<NSObject, Foo>) but I don't think its a solution because the NSObject protocol only exists for base NSObject, not subclasses, First you don't use NSObject, you use NSObjectProtocol because in Swift you can't name them the same thing since the type names would be ambiguous. Second, this works just fine assuming Foo is a protocol: code:
If you are talking about identifying the return type as being an instance of class X while also implementing protocol Y, then you can use a generic method: code:
|
# ? Aug 4, 2014 05:30 |
|
Did += for Array just die with the new beta?
|
# ? Aug 4, 2014 22:29 |
|
Jeeze, Apple wasn't kidding when they talked about possibly changing the syntax. It's at the moment quite annoying to have to do this in every single one of my classes that inherits from UIView: code:
I'm just curious if this is overzealousness at the moment, or how this whole "required" business is going to shake out.
|
# ? Aug 5, 2014 02:10 |
|
I warned Doug this would happen. That particular diagnostic enhancement is obvious and coming. We may also need to add a simple way to say that you don't implement something. But yes, we are quite serious about breaking existing code if we think it makes the language better, and we plan to continue breaking things all the way to 2.0 and possibly beyond (although we hope to at least substantially automate updating from real released versions).
|
# ? Aug 5, 2014 03:31 |
|
Axiem posted:This would be a little better if when I got the message that my class doesn't implement all my superclass's required members, I had a way of seeing what I don't actually implement. You can, you just have to expand the error in the issue navigator.
|
# ? Aug 5, 2014 03:58 |
|
|
# ? May 14, 2024 17:58 |
|
Interacting with API that require plist types is making my beautiful swift code look horrifying. Edit: actually looks like it might have been due to using an enum.case as a key (even though it was an NSString type) Kallikrates fucked around with this message at 15:37 on Aug 6, 2014 |
# ? Aug 6, 2014 14:31 |