|
Filburt Shellbach posted:The Advanced talk was great. I'm glad the syntax mungling examples were tempered by words of caution. I've got a couple questions I haven't seen asked, sorry if they were already asked and I missed em... Is Swift going to enable better refactoring support in Xcode? I really, really miss Resharper when doing ObjC dev Also, I'm writing an iPhone app that makes a lot of use of raw C byte arrays for performance, is there a performant way to allocate and read/write a raw c-style array with Swift, or should I leave that bit in ObjC?
|
# ¿ Jun 6, 2014 21:02 |
|
|
# ¿ Apr 29, 2024 05:48 |
|
Meat Street posted:It was a design decision of the language to not have exceptions and I doubt they'll double back on that, nor would I use them if they were added, but this does raise (heh) an interesting question: does the Core Data talk this year have anything to say about usage patterns in Swift? I've kinda given up using Swift for my iOS project (just time constraints) so now I'm facing the usual problem of learning about an awesome new PL and really wanting to try it but having no idea what to actually do with it, so I'm burning through a few Project Euler problems in the Playground, and its a joy. Even the numerous problems that are basically variations on 'how many different ways are there to do xyz' are fun because Swift makes writing your own little expressive DSLs and abstractions so easy.
|
# ¿ Jun 8, 2014 19:18 |
|
Possibly stupid swift noob question - how come I can do code:
but I can't do code:
|
# ¿ Apr 29, 2015 09:39 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
rjmccall posted:There's a Swift component.
|
# ¿ May 12, 2015 21:53 |
|
Is there a possibility of being able to assign from switch statements? I'm writing a Chip-8 interpreter in Swift, decoding instructions using tuples in a switch statement, but each operator needs to return a value. Right now I set a 'result' value in every case statement, but it would be nice if I could do this...code:
|
# ¿ May 24, 2015 15:03 |
|
Oh, well thats quite nice isn't it! Thanks! Edit to add: that works but you have to be explicit about the return type, type inference doesn't seem to be able to figure it out. I've got another question, would it be possible to have a 'strict' version of typealias that means that the alias is treated as it's own distinct type, rather than just an alias? So something like this would create a compiler error: code:
toiletbrush fucked around with this message at 17:09 on May 26, 2015 |
# ¿ May 24, 2015 20:13 |
|
I got another 'expression was too complex to be solved in reasonable time' compiler exception...code:
Also, it compiles fine if I do '$0 as Int', although you don't get any compiler warnings if you pass an array of non-Ints, and instead the app crashes...will this be possible in the future?
|
# ¿ Jun 3, 2015 13:49 |
|
All awesome stuff, althought I thought there was a typo in some docs when it talked about generics in ObjC...until I found out...you added generics to ObjC?!
|
# ¿ Jun 9, 2015 13:01 |
|
I totally love the way that Swift handles errors, but how come the 'throws' keyword comes between the parameters and return type? Its just 'myFailingFunction() throws -> Int { ... }' reads a bit like the function throws an Int...but I guess it makes sense as throwing an exception is sort of a possible return type..
|
# ¿ Jun 18, 2015 08:45 |
|
Is the idea of a 'strict' version of typealias (eg typealias Gram = Int and have the compiler complain if you try to pass an Int to a Gram parameter or add an Int to a Gram) a really bad one for an obvious dumb reason I haven't spotted? If not, is there any way to implement this in Swift, or would it be a possible future feature?
|
# ¿ Jun 25, 2015 10:53 |
|
I'm really enjoying Swift, I still love c# but I'm finding myself wishing I could do swift-thing in C# a lot more than the other way round, which I'm kinda suprised about. The only thing that I'm still not comfortable with is extensions and generics, using typealiases in code like this: code:
|
# ¿ Jul 16, 2015 13:05 |
|
Is something like 'yield' in the pipeline for Swift? Also assigning to vars directly from switch statements? Someone mentioned before that you can wrap the switch in a closure, but type inference doesn't seem able to infer the type unless you annotate the var you are assigning to, and it feels a bit clunky.
|
# ¿ Aug 2, 2015 22:41 |
|
I came across a surprising compiler confuser just now...code:
code:
|
# ¿ Sep 5, 2015 15:43 |
|
Is there any way in Swift to generate a copy of a struct but with one or more values changed? So given a struct like...code:
code:
|
# ¿ Feb 25, 2016 12:49 |
|
Ah cool...alas I'm being super strict + anal about no var's whatsoever! Purely for a learning exercise. Do you think it might be a feature for the future?
|
# ¿ Feb 25, 2016 23:30 |
|
rjmccall posted:Instinctively making everything immutable is definitely a sign of importing philosophy from other languages, though. On a similar note, are there any plans to have a 'strict' version of typealias? Or is it just a bad idea?
|
# ¿ Mar 3, 2016 14:52 |
|
I don't really know Haskell at all but it looks like it, yeah...so having...code:
|
# ¿ Mar 4, 2016 01:25 |
|
I've written an extension method on Int called '.asRgbColor' so you can do...code:
Edit: I filed a bug, looks like the parser is confused because the 'a' at the start of asRgbColor is valid in a hex string, so it tries to parse it as a floating point hex literal! Changing the var name to toRgbColor fixes the issue... toiletbrush fucked around with this message at 00:16 on Jun 10, 2016 |
# ¿ Jun 9, 2016 23:50 |
|
I'm trying to build a tiny new Swift 3.0 MacOS app to profile and I'm getting a compiler error...it builds fine without warning running it generally but as soon as I build for profiling I get the following error...code:
Edit to add: I've deleted code all the way down to just the ViewController stub you get for SpriteKit apps and I still get the error toiletbrush fucked around with this message at 22:25 on Jul 5, 2016 |
# ¿ Jul 5, 2016 22:20 |
|
There's a big thread going on on the Swift evo mailing list at the moment about making it explicit when implementing a method from a protocol, like...code:
code:
|
# ¿ Sep 21, 2016 10:22 |
|
|
# ¿ Apr 29, 2024 05:48 |
|
I'd agree with that ^^ I can see the problems they're trying to avoid, but I think peppering the code with noise is the wrong approach and would be much better solved by better intellisense once Apple have hired all the R# devs to work on XCode.
|
# ¿ Sep 22, 2016 10:22 |