Re: [swift-users] Memory used by enums

2016-04-05 Thread Daniel Eggert via swift-users
On 05 Apr 2016, at 01:57, Jonathan Hull via swift-users wrote: > > I had a quick question on the memory used by enums with associated values in > the current implementation. If I have an enum like the following: > > enum MyEnum { > case mostCommonlyUsed > case somewhatCommon (Int,

Re: [swift-users] Optionals inside Dictionary where Value = Any

2016-01-06 Thread Daniel Eggert via swift-users
> On 06 Jan 2016, at 12:20, Dmitri Gribenko wrote: > > On Wed, Jan 6, 2016 at 12:47 PM, Daniel Eggert via swift-users > wrote: >> I’m storing an Int? inside a [String:Any] but I can’t retrieve it again. Is >> this expected behaviour or a bug in Swift? >> >&g

[swift-users] Optionals inside Dictionary where Value = Any

2016-01-06 Thread Daniel Eggert via swift-users
I’m storing an Int? inside a [String:Any] but I can’t retrieve it again. Is this expected behaviour or a bug in Swift? /Daniel % swift Welcome to Apple Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 1f2908b4f7). Type :help for assistance. 3> let d: [String:Any] = ["foo": (nil

Re: [swift-users] ARC // Precise Lifetime Semantics

2016-01-06 Thread Daniel Eggert via swift-users
ed.passUnretained(mapped) > defer { unmanaged.release() } > > let buffer = UnsafeBufferPointer(start: UnsafePointer(base), > count: size / sizeof(Void)) > return someFunction(buffer) > } > > Best Regards, > Chris > > > On 05 Jan 2016, at 16:57, Daniel Eg

[swift-users] ARC // Precise Lifetime Semantics

2016-01-05 Thread Daniel Eggert via swift-users
How do I extend the lifetime of a variable, i.e. make sure that ARC is less aggressive? clang has an attribute called objc_precise_lifetime — does Swift have something similar? I have this code: do { var base = UnsafePointer() var size = Int() let mapped = dispatch_data_create_m

Re: [swift-users] error: value of type 'Self.SubSequence' has no member 'Distance'

2015-12-26 Thread Daniel Eggert via swift-users
> On 24 Dec 2015, at 03:11, Dmitri Gribenko wrote: > > On Wed, Dec 23, 2015 at 3:24 PM, Daniel Eggert via swift-users > wrote: >> I have an array of String and need to call withCString on each one and then >> pass the resulting array of UnsafePointer to a C api. The un

Re: [swift-users] C vararg: Swift Package Manager and System Modules

2015-12-23 Thread Daniel Eggert via swift-users
On 18 Dec 2015, at 20:42, Chris Lattner wrote: > > >> On Dec 17, 2015, at 1:47 PM, Daniel Eggert via swift-users >> wrote: >> >> If I need access to the C fcntl(2): >> >> int fcntl(int, int, ...) >> >> can I get the swift-package-manage

[swift-users] error: value of type 'Self.SubSequence' has no member 'Distance'

2015-12-23 Thread Daniel Eggert via swift-users
I have an array of String and need to call withCString on each one and then pass the resulting array of UnsafePointer to a C api. The unsafe pointer is only valid within the scope of withCString. So I built the following, but the compiler doesn’t like it: % swift scopedReduceAndApply.swift sco

Re: [swift-users] C vararg: Swift Package Manager and System Modules

2015-12-18 Thread Daniel Eggert via swift-users
> On 17 Dec 2015, at 22:47, Daniel Eggert via swift-users > wrote: > > If I need access to the C fcntl(2): > > int fcntl(int, int, ...) > > can I get the swift-package-manager or swift-build-tool to compile C code > that wraps this into a no

[swift-users] C vararg: Swift Package Manager and System Modules

2015-12-17 Thread Daniel Eggert via swift-users
If I need access to the C fcntl(2): int fcntl(int, int, ...) can I get the swift-package-manager or swift-build-tool to compile C code that wraps this into a non-vararg version: int SocketHelper_fcntl_setFlags(int const fildes, int const flags) { return fcntl(fildes, F_SETFL, flags);