Re: [swift-users] Localization in Swift.

2016-11-02 Thread Zhao Xin via swift-users
Hello everyone. Thanks to you all for replies in this thread. I am currently working on a Xcode Extension for this purpose. I would like to bring it to github in this week. This will be my first Xcode extension, also my first github open sourced project. Zhaoxin On Thu, Nov 3, 2016 at 6:14 AM,

Re: [swift-users] Type checker not accepting subclass(protocol conformance) as a valid type inside a closure in a protocol with constraint where Self: MyClass

2016-11-02 Thread Jordan Rose via swift-users
Hi, Henrique. This is a correct error message. Consider this use case: struct Impl: PersistentModel { func doTheThing() } func callback(_ objs: [Impl]?, _ error: Error?) -> Void? { return objs.first?.doTheThing() } find2(withBlock: callback) // direct call for clarity Clearly here the ‘callb

Re: [swift-users] What is "binding" memory?

2016-11-02 Thread Jordan Rose via swift-users
> On Nov 2, 2016, at 15:50, Dave Abrahams via swift-users > wrote: > > > on Wed Nov 02 2016, Andrew Trick > wrote: > >>> On Nov 2, 2016, at 12:58 PM, Dave Abrahams via swift-users >>> wrote: >>> At the top of the migration guide is a link to the memory mo

Re: [swift-users] What is "binding" memory?

2016-11-02 Thread Andrew Trick via swift-users
> On Nov 2, 2016, at 3:50 PM, Dave Abrahams wrote: > >> The original poster seemed to have the impression that the operation >> of binding memory itself might affect program state, > > Formally speaking, it does! Oh boy. I keep failing at this. How does one formally distinguish between seman

Re: [swift-users] What is "binding" memory?

2016-11-02 Thread Dave Abrahams via swift-users
on Wed Nov 02 2016, Andrew Trick wrote: >> On Nov 2, 2016, at 12:58 PM, Dave Abrahams via swift-users >> wrote: >> >>> At the top of the migration guide is a link to the memory model explanation: >>> > https://github.com/apple/swift-evolution/blob/master/proposals/0107-unsaferawpointer.md#mem

Re: [swift-users] What is "binding" memory?

2016-11-02 Thread Andrew Trick via swift-users
> On Nov 2, 2016, at 12:58 PM, Dave Abrahams via swift-users > wrote: > >> At the top of the migration guide is a link to the memory model explanation: >> https://github.com/apple/swift-evolution/blob/master/proposals/0107-unsaferawpointer.md#memory-model-explanation >> >> "A memory location's

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

2016-11-02 Thread Chris Lattner via swift-users
On Nov 1, 2016, at 9:50 PM, Shyamal Chandra wrote: > Hi Chris, > > First of all, there is tremendous instability with Xcode Playgrounds. Hi Shyamal, The vast majority of the instability of playgrounds is a result of the compiler code which is already open source. I look forward to you sendin

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Dave Abrahams via swift-users
on Wed Nov 02 2016, Jens Alfke wrote: >> On Nov 2, 2016, at 12:50 PM, Dave Abrahams via swift-users >> wrote: >> >> In my opinion, we can and must do much better for Swift. If there's >> something about “%” formatting that you particularly value, I'd like to >> know about it, so I can make s

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Greg Parker via swift-users
> On Nov 2, 2016, at 1:08 PM, Joe Groff via swift-users > wrote: > >> On Nov 2, 2016, at 1:00 PM, Philippe Hausler > > wrote: >> >> See: >> >> https://github.com/apple/swift-corelibs-foundation/blob/d015466450b2675037c6f1ace8e17e73050ccfb9/Foundation/NSURL.swift#L56

Re: [swift-users] Element vs. Iterator.Element

2016-11-02 Thread Slava Pestov via swift-users
I don’t remember the details, but IIRC ‘Iterator’ is an inferred associated type on Array, so it cannot appear in the ‘where’ clause of an extension. This is a known limitation of the name lookup code — presently it cannot recur into associated type inference due to circularity. We plan on addre

Re: [swift-users] wishing I could cast (sort of) to protocol with associated type

2016-11-02 Thread Jordan Rose via swift-users
The only real way to do this today is to have two layers of protocol: protocol SpecialControllerBase { var currentValueBase: SpecialValue? { get } } protocol SpecialController: SpecialControllerBase { associatedtype SpecialValueType : SpecialValue var currentValue: SpecialValueType? { get }

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Bernardo Breder via swift-users
2016-11-02 18:36 GMT-02:00 Joe Groff : > > On Nov 2, 2016, at 1:16 PM, Bernardo Breder via swift-users < > swift-users@swift.org> wrote: > > In my http server i want to manager the memory all the time that we close > a socket, like the example of manager in this link: > http://stackoverflow.com/qu

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Jens Alfke via swift-users
> On Nov 2, 2016, at 1:42 PM, Bernardo Breder via swift-users > wrote: > > The algorithm that i send is a example of server code and this code will > execute in a ubuntu environment. When i install in the ubuntu, the swiftc > show me that the autoreleasepool is "use of unresolved identifier

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Brent Royal-Gordon via swift-users
(Resending something that was accidentally off-list.) > On Nov 1, 2016, at 11:09 PM, Jens Alfke via swift-users > wrote: > > I don’t think the ExpressibleByStringInterpolation protocol provides enough > information to make this work. It hands the implementation a list of values > to concatena

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Jens Alfke via swift-users
> On Nov 2, 2016, at 12:50 PM, Dave Abrahams via swift-users > wrote: > > In my opinion, we can and must do much better for Swift. If there's > something about “%” formatting that you particularly value, I'd like to > know about it, so I can make sure it's accomodated. It offers more control

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Jordan Rose via swift-users
> On Nov 2, 2016, at 13:36, Joe Groff via swift-users > wrote: > >> >> On Nov 2, 2016, at 1:16 PM, Bernardo Breder via swift-users >> mailto:swift-users@swift.org>> wrote: >> >> In my http server i want to manager the memory all the time that we close a >> socket, like the example of manage

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Joe Groff via swift-users
> On Nov 2, 2016, at 1:16 PM, Bernardo Breder via swift-users > wrote: > > In my http server i want to manager the memory all the time that we close a > socket, like the example of manager in this link: > http://stackoverflow.com/questions/25860942/is-it-necessary-to-use-autoreleasepool-in-a-

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Bernardo Breder via swift-users
In my http server i want to manager the memory all the time that we close a socket, like the example of manager in this link: http://stackoverflow.com/questions/25860942/is-it-necessary-to-use-autoreleasepool-in-a-swift-program Algorithm that show the ideia: *func request(content) { ... }* *let

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Joe Groff via swift-users
> On Nov 2, 2016, at 1:00 PM, Philippe Hausler wrote: > > See: > > https://github.com/apple/swift-corelibs-foundation/blob/d015466450b2675037c6f1ace8e17e73050ccfb9/Foundation/NSURL.swift#L561 > >

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Jordan Rose via swift-users
I don’t know, this isn’t really a good Swift API either. Some of the other bare pointer cases we changed to return arrays instead for this reason, like String’s version of cString(using:). https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/NSStringAPI.swift#L413 I am actual

Re: [swift-users] What is "binding" memory?

2016-11-02 Thread Dave Abrahams via swift-users
on Tue Nov 01 2016, Andrew Trick wrote: >> On Nov 1, 2016, at 11:55 AM, Manfred Schubert via swift-users >> wrote: >> >> The "UnsafeRawPointer Migration" guide talks about "binding memory >> to a type“ as if that was a well known term. I have never heard of >> it yet though, and googling it r

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Philippe Hausler via swift-users
See: https://github.com/apple/swift-corelibs-foundation/blob/d015466450b2675037c6f1ace8e17e73050ccfb9/Foundation/NSURL.swift#L561 This is far and few between of cases t

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Jordan Rose via swift-users
I’m confused about this. Shouldn’t you be able to get away with using +1 convention everywhere? What needs to have arbitrary lifetime-extension in an ARC-ified language? Jordan > On Nov 2, 2016, at 12:23, Philippe Hausler wrote: > > So there are issues we have in swift-corelibs that suffer(le

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Philippe Hausler via swift-users
So trivially we could do something along these lines to “solve it” in swift-corelibs-foundation instead of polluting the swift standard library with objective-c-isms on Linux. internal class NSAutoreleasePool { fileprivate static var _current = NSThreadSpecific() internal static var cur

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Dave Abrahams via swift-users
on Tue Nov 01 2016, Jens Alfke wrote: >> On Nov 1, 2016, at 10:40 PM, Zhao Xin wrote: >> >> For example, if I want show the user that I have to ask him to give me >> permission of a folder, the > `url.path` has no need to translate. > > We’re getting off-topic, but paths do need to be transla

[swift-users] wishing I could cast (sort of) to protocol with associated type

2016-11-02 Thread Robert Nikander via swift-users
Hi, In the following code, I want to test if x is a `SpecialController`. If it is, I want to get the `currentValue` as a `SpecialValue`. How do you do this? If not with a cast, then some other technique. I understand the error, and that SpecialController by itself is not a simple type to cast

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Jens Alfke via swift-users
> On Nov 2, 2016, at 11:23 AM, Marco S Hyman via swift-users > wrote: > > On Nov 1, 2016, at 11:42 PM, Zhao Xin via swift-users > wrote: >> >> I have already give a workable implementation above. > > Your implementation assume \(x) is always %@x. It’s also not an implementation. It’s just

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Philippe Hausler via swift-users
So there are issues we have in swift-corelibs that suffer(leak) because we don't have ARPs on Linux. It would be super nice to have a retain until scope end concept for swift core libs where autorelease would be an accessor in unmanaged that would retain the object until the arp ends scope. Sen

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Jens Alfke via swift-users
> On Nov 2, 2016, at 09:42, Joe Groff via swift-users > wrote: > > Autoreleasepools are an ObjC compatibility feature. They aren't necessary in > standalone Swift. So Swift’s ref-counting doesn’t use any autorelease mechanism? I was assuming it did (even if it’s not identical to Obj-C’s.) I

Re: [swift-users] Localization in Swift.

2016-11-02 Thread Marco S Hyman via swift-users
On Nov 1, 2016, at 11:42 PM, Zhao Xin via swift-users wrote: > > I have already give a workable implementation above. Your implementation assume \(x) is always %@x. What does it do when given -- to use an example from the swift book: "\(multiplier) times 2.5 is \(Double(multiplier) * 2.5)”

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Bernardo Breder via swift-users
I want to manager the memory, using the autoreleasepool block, with ubuntu environment, as we can do with Xcode. 2016-11-02 15:34 GMT-02:00 Joe Groff : > > On Nov 2, 2016, at 10:17 AM, Jordan Rose wrote: > > > On Nov 2, 2016, at 09:42, Joe Groff via swift-users > wrote: > > > On Nov 1, 2016, at

Re: [swift-users] What is "binding" memory?

2016-11-02 Thread Rien via swift-users
> On 02 Nov 2016, at 18:07, Manfred Schubert via swift-users > wrote: > > Am 01.11.2016 um 21:40 schrieb Andrew Trick : >> >> I’m not sure I like the “prepares the memory” language myself. Binding >> memory communicates to the compiler that the memory locations are safe for >> typed access.

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

2016-11-02 Thread has via swift-users
Jens Alfke wrote: > Back when I worked at Apple I used to drop in on Steve and tell him > the metal UI appearance sucked. He’d chuckle in his kindly way, > and then nail my head to the floor. Now Tim Cook owes me a new keyboard! has ___ swift-users

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Joe Groff via swift-users
> On Nov 2, 2016, at 10:17 AM, Jordan Rose wrote: > >> >> On Nov 2, 2016, at 09:42, Joe Groff via swift-users > > wrote: >> >>> >>> On Nov 1, 2016, at 6:40 PM, Bernardo Breder via swift-users >>> mailto:swift-users@swift.org>> wrote: >>> >>> Hello, >>> >>> I w

Re: [swift-users] What is "binding" memory?

2016-11-02 Thread Manfred Schubert via swift-users
Am 01.11.2016 um 21:43 schrieb Michael Ilseman : > > This is more so a semantic distinction rather than some kind of physical > operation. The memory is not altered, but all reads and writes to that memory > location have to be through the “bound type”. If it’s “bound” to some type T, > you mus

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Jordan Rose via swift-users
> On Nov 2, 2016, at 09:42, Joe Groff via swift-users > wrote: > >> >> On Nov 1, 2016, at 6:40 PM, Bernardo Breder via swift-users >> wrote: >> >> Hello, >> >> I want to create a mini http server project and execute at Ubuntu 15. The >> Xcode compile and access the function "autoreleasepo

Re: [swift-users] What is "binding" memory?

2016-11-02 Thread Manfred Schubert via swift-users
Am 01.11.2016 um 21:40 schrieb Andrew Trick : > > I’m not sure I like the “prepares the memory” language myself. Binding memory > communicates to the compiler that the memory locations are safe for typed > access. Nothing happens at runtime--until someone writes a type safety > sanitizer. So n

Re: [swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Joe Groff via swift-users
> On Nov 1, 2016, at 6:40 PM, Bernardo Breder via swift-users > wrote: > > Hello, > > I want to create a mini http server project and execute at Ubuntu 15. The > Xcode compile and access the function "autoreleasepool", but when i compile > the same code at Ubuntu, this function not found >

[swift-users] Autoreleasepool for Ubuntu

2016-11-02 Thread Bernardo Breder via swift-users
Hello, I want to create a mini http server project and execute at Ubuntu 15. The Xcode compile and access the function "autoreleasepool", but when i compile the same code at Ubuntu, this function not found For example, i can compile the code above at Xcode: while true { autoreleasepool {