[swift-users] String initializers and developer ergonomics

2016-05-07 Thread Austin Zheng via swift-users
Hello Swift users, I wanted to run something past you folks and get some opinions/feedback. About a month ago on Hacker News I saw someone commenting about how Swift's string-handling code was unbearably slow (3 seconds to run a code sample, vs. 0.8 in Java). I asked him to provide the code, an

Re: [swift-users] Robotics with Swift

2016-05-08 Thread Austin Zheng via swift-users
This is great news! I have a BBB and a RC truck I've been meaning to build a robot out of this summer, and this gives me an option to interface with the hardware besides the Python interface. Brad Larson (https://twitter.com/bradlarson) works at a company called SonoPlot that makes robots for rese

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

2016-05-09 Thread Austin Zheng via swift-users
r via swift-users < swift-users@swift.org> wrote: > > On May 9, 2016, at 10:28 AM, Jacob Bandes-Storch via swift-users < > swift-users@swift.org> wrote: > > On Mon, May 9, 2016 at 10:25 AM, Joe Groff via swift-users < > swift-users@swift.org> wrote: > >>

Re: [swift-users] Swift 3 Questions

2016-05-23 Thread Austin Zheng via swift-users
Hi Simon, This behavior is intentional; implicit bridging conversions are slated for removal in Swift 3. More information: https://github.com/apple/swift-evolution/blob/master/proposals/0072-eliminate-implicit-bridging-conversions.md

Re: [swift-users] plugins, verifiable code?

2016-05-25 Thread Austin Zheng via swift-users
Hi Robert, To my knowledge, nothing like this has been seriously proposed. You may want to mail the swift-evolut...@swift.org list and start a discussion there. I think a good way to approach your objectives might be for Swift to adopt some sort of taint analysis-like checking, much like what R

Re: [swift-users] Unsafe(Mutable)Pointer (suc)predecessor and advancedBy functions

2016-05-26 Thread Austin Zheng via swift-users
On Thu, May 26, 2016 at 10:31 AM, Adrian Zubarev via swift-users < swift-users@swift.org> wrote: > So theoretically I could build a wrapper type for Unsafe(Mutable)Pointer > which will be safe to use and never exceed the allocated range! > Yeah, if I remember correctly this is actually how the Swi

Re: [swift-users] Unsafe(Mutable)Pointer (suc)predecessor and advancedBy functions

2016-05-26 Thread Austin Zheng via swift-users
This is where it gets tricky. When you create a chunk of memory using 'UnsafeMutablePointer.memory()' or 'alloc()', it's as if you are programming in C with 'malloc' and 'free'. The memory you create and the objects you put in that memory don't participate in ARC - the runtime will not track refer

Re: [swift-users] UnsafeMutablePointer vs. UnsafeMutablePointer

2016-06-01 Thread Austin Zheng via swift-users
This shouldn't be something you need to worry about. The mechanism the OS uses to handle memory per process is different from the mechanism your process uses to allocate memory, and the OS should reclaim all the memory that your app used (whether it was 'leaked' or not). More info: http://stac

Re: [swift-users] Coding style for internal/private variables

2016-06-01 Thread Austin Zheng via swift-users
I've actually used the _underscore convention in Swift to denote "private" members that nobody outside the type should touch, but that I want to expose to an extension on that type defined in a different file. It's a convention that works decently well with a little discipline. Some time back,

Re: [swift-users] String Comparisons in Swift

2016-06-02 Thread Austin Zheng via swift-users
You should be able to use ==. Are the lengths of your strings the same length? readLine() has a strip newlines parameter that is true by default. Best, Austin Sent from my iPhone > On Jun 2, 2016, at 12:07 PM, John Myers via swift-users > wrote: > > I've had some difficulty comparing stri

Re: [swift-users] Discrepancy between sharing internal Swift symbols with Obj-C when in an app vs a framework target

2016-06-04 Thread Austin Zheng via swift-users
This is probably a solution to a different issue, but what happens if you declare your "should be visible from Objective-C" swift methods as 'dynamic'? Austin > On Jun 4, 2016, at 11:55 AM, Jens Alfke via swift-users > wrote: > > >> On Jun 4, 2016, at 11:29 AM, Kevin Lundberg via swift-users

Re: [swift-users] Swift Binary Size vs. Obj-C

2016-06-15 Thread Austin Zheng via swift-users
Swift binaries are so massive currently because there's no ABI stability, therefore the runtime and support libraries must be packaged with every application. This should change in the future. Best, Austin On Wed, Jun 15, 2016 at 3:43 PM, Seth Friedman via swift-users < swift-users@swift.org> wro

Re: [swift-users] Swift Binary Size vs. Obj-C

2016-06-15 Thread Austin Zheng via swift-users
Sorry, I totally missed the part where you mentioned the runtime libs. I assume you're compiling your Objective-C code using the `-Os` optimization level? Unfortunately, it doesn't seem like swiftc has any flags for trading off speed and binary size. Part of the size discrepancy is almost certainl

Re: [swift-users] Swift to Javascript

2016-06-21 Thread Austin Zheng via swift-users
The great thing about Swift being open-source is that anyone can help make it a better language! Here's a good starting point: https://kripken.github.io/emscripten-site/index.html Best, Austin > On Jun 21, 2016, at 9:44 PM, Mr Bee via swi

Re: [swift-users] Bls: Re: Swift to Javascript

2016-06-21 Thread Austin Zheng via swift-users
If you want something supported by Apple, the procedure is to propose it on the swift-evolution list. However, Swift has a very specific set of development priorities right now, so they are almost certainly not going to accept any new proposals for compiler backends or transpilation support for

Re: [swift-users] Why does RangeReplaceableCollection require an empty initialiser?

2016-07-06 Thread Austin Zheng via swift-users
Would this require a swift-evolution review, since it's technically an API change? (removing the initializer requirement is something I am also interested in seeing...) Austin On Wed, Jul 6, 2016 at 7:05 PM, Dave Abrahams via swift-users < swift-users@swift.org> wrote: > > on Wed Jul 06 2016, Ti

Re: [swift-users] object.self?

2016-07-08 Thread Austin Zheng via swift-users
Hi Rick, If you have a type (let's call it "T"), you can use it two ways: * As a type, or part of a type, like such: "let x : T = blah()" * As a value, just like any other variable, function argument, property, etc. In the second case (type-as-value), you need to append ".self" to the type name

Re: [swift-users] object.self?

2016-07-09 Thread Austin Zheng via swift-users
Yes, as far as I know 'foo' and 'foo.self' are equivalent. I don't actually know why the latter exists, except in analogy to "T.self". There was a mistake in my response; the metatype of 'foo' is not 'foo.self', it is 'foo.dynamicType' (or whatever new form dynamicType is going to take in Swift 3)

Re: [swift-users] Syntax for extending a struct conforming to a protocol with constraint

2016-07-10 Thread Austin Zheng via swift-users
You can't do this yet, but it's on the roadmap: https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#conditional-conformances- Austin > On Jul 9, 2016, at 10:54 PM, 褚晓敏 via swift-us

Re: [swift-users] Swift and Xcode along with Playgrounds is full of bugs

2016-09-13 Thread Austin Zheng via swift-users
Hi Shyamal, Please share with us the SLA you signed with Apple that guarantees you any level of paid support with regards to Swift, or alternatively an invoice that shows us how much you paid for a license to use the Linux port of Swift. Best regards, Austin > On Sep 13, 2016, at 7:24 PM, Shya

Re: [swift-users] Data reflection metadata?

2016-10-13 Thread Austin Zheng via swift-users
You probably want to check out this repo: https://github.com/Zewo/Reflection It's clever stuff. Really, really reliant on implementation details of the runtime to function, so I'd be loathe to use it in any sort of production application, but as a proof of c

Re: [swift-users] (no subject)

2017-03-12 Thread Austin Zheng via swift-users
The source code on GitHub _is_ full and complete. Check out https://github.com/apple/swift/blob/master/stdlib/public/core/Collection.swift#L1336-L1338 for the implementation of `count`. RandomAccessCol

Re: [swift-users] Why is static a keyword?

2017-05-11 Thread Austin Zheng via swift-users
`class` and `static` in classes have subtly different meanings, if I recall correctly. A `class` declaration can be overriden in subclasses; a `static` one can't. Best, Austin On Thu, May 11, 2017 at 10:04 AM, Zhao Xin via swift-users < swift-users@swift.org> wrote: > No. I think it is just a co

Re: [swift-users] There is a way to see pending features or discussions in complexity order?

2017-06-12 Thread Austin Zheng via swift-users
Hi Mariano, If you want to contribute, you should create an account at the bug tracker at https://bugs.swift.org/. You can then look for bugs marked with the `StarterBug` tag, which are simple tasks or enhancements that are explicitly called out as appropriate for new contributors. If you just wa

Re: [swift-users] Removed discussions in doc for Swift 4. Why?

2017-06-12 Thread Austin Zheng via swift-users
The currying syntax was removed in Swift 3 (see https://github.com/apple/swift-evolution/blob/master/proposals/0002-remove-currying.md). I'm not aware, though, of any proposal in the pipeline to remove variadic arguments, so it's not clear why the book should have removed discussion about them. Au

Re: [swift-users] can we express "does not conform to a particular protocol"?

2017-07-03 Thread Austin Zheng via swift-users
I'm pretty sure solutions like the one you proposed are impossible, unfortunately :(. The compiler has to choose the static override at compile time, but it can't tell until runtime whether the type conforms to `Equatable` or not (because of retroactive conformance). It's also not possible to u

Re: [swift-users] Justification for Swift Design Decisions?

2017-10-31 Thread Austin Zheng via swift-users
To expand on this, most (if not all) the proposals in the list of proposals on GitHub (https://github.com/apple/swift-evolution/tree/master/proposals) have a "Rationale" link to a mailing list archive post by one of the Swift core team members explaining why a certain decision was reached. Those ar

Re: [swift-users] Justification for Swift Design Decisions?

2017-10-31 Thread Austin Zheng via swift-users
Sorry for the second email, but there's one link in particular that I think might be valuable (and is not easily found any other way). This little discussion by Chris Lattner discusses the dynamic nature of some popular programming languages compared to Swift, and has some explanation as to why Swi

[swift-users] Capturing references to initializers?

2015-12-10 Thread Austin Zheng via swift-users
Hello Swift users, I have a question about capturing references to initializers. You can do the following right now: struct Foo { let number : Int // This type has a single initializer init() { number = 10 } } let a = Foo.init // a's type: () -> Foo So far so good. Now