<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">See:</div><div class=""><br class=""></div><a href="https://github.com/apple/swift-corelibs-foundation/blob/d015466450b2675037c6f1ace8e17e73050ccfb9/Foundation/NSURL.swift#L561" class="">https://github.com/apple/swift-corelibs-foundation/blob/d015466450b2675037c6f1ace8e17e73050ccfb9/Foundation/NSURL.swift#L561</a><div class=""><br class=""></div><div class="">This is far and few between of cases that it would be useful but there are a few APIs that we have not been able to express without being able to autorelease items. Most of which we have either forbidden in Linux or redesigned because they were sub-par swift experiences. However it seems reasonable to have a minimal shim to provide cross platform code compatibility even if it does next to nothing. That way trivial code as the original issue showed can easily be directly compiled on either platform without littering gnarly #ifdefs about.<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 2, 2016, at 12:55 PM, Jordan Rose <<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">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?</div><div class=""><br class=""></div><div class="">Jordan</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 2, 2016, at 12:23, Philippe Hausler <<a href="mailto:phausler@apple.com" class="">phausler@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><div style="direction: inherit;" class="">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.</div><br class="">Sent from my iPhone</div><div class=""><br class="">On Nov 2, 2016, at 10:17 AM, Jordan Rose <<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 2, 2016, at 09:42, Joe Groff via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">On Nov 1, 2016, at 6:40 PM, Bernardo Breder via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:<br class=""><br class="">Hello,<br class=""><br class="">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<br class=""><br class="">For example, i can compile the code above at Xcode:<br class=""><br class="">while true {<br class=""> autoreleasepool {<br class=""> var test: Data = "HTTP/1.1 200 OK\r\nContent-Length: 1\r\n\r\na".data(using: .utf8)!<br class=""> }<br class="">}<br class=""><br class="">But when i try to compile at Ubuntu:<br class=""><br class="">git@breder:~$ cat main.swift <br class="">import Foundation<br class=""><br class="">while true {<br class=""> autoreleasepool {<br class=""> var test: Data = "HTTP/1.1 200 OK\r\nContent-Length: 1\r\n\r\na".data(using: .utf8)!<br class=""> }<br class="">}<br class=""><br class="">git@breder:~$ swiftc main.swift<span class="Apple-converted-space"> </span><br class="">main.swift:4:5: error: use of unresolved identifier 'autoreleasepool'<br class=""> autoreleasepool {<br class=""> ^~~~~~~~~~~~~~~<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Autoreleasepools are an ObjC compatibility feature. They aren't necessary in standalone Swift.</span></div></blockquote><br class=""></div><div class="">But they <i class="">are</i> necessary in Swift programs on Apple platforms (that don’t use RunLoop, anyway). Philippe, what do you think? What’s the right way to write cross-platform code that doesn’t use RunLoop or dispatch_main for an implicit autorelease pool?</div><div class=""><br class=""></div><div class="">(/me remembers +[NSAutoreleasePool drain] from the ObjC-GC days)</div><br class=""><div class="">Jordan</div></div></blockquote></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div></body></html>