Re: [swift-users] CustomStringConvertible?

2017-09-09 Thread Rien via swift-users
Ah, yes. It is possible to ‘store’ it as a fixed string. But I would still expect the compiler to treat it as if it were a computed property. Given that this is a protocol and a protocol cannot define stored properties. (yet anyway) OTOH, what do I know about compilers… lol! Regards, Rien

Re: [swift-users] CustomStringConvertible?

2017-09-08 Thread Rien via swift-users
It cannot be ‘stored’ I would think. I always compute my implementations. Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Balancingrock Project: http://swiftfire.nl - An HTTP(S) web server framework in Swift > On 08 Sep 2017, at

[swift-users] Very large NSNumber values

2017-06-26 Thread Rien via swift-users
I was working with very large NSNumber values and noticed some odd behaviour when converting these values to integers. An NSNumber with the value +1e+40 will when converted to Ints produce integers wit the value zero for Int8, UInt8, Int16, UInt16, Int32 and UInt32. But for Int64 it will

Re: [swift-users] JSON keys survey

2017-06-23 Thread Rien via swift-users
> On 23 Jun 2017, at 18:42, Tony Parker via swift-users > wrote: > > Hi all, > > This has come up a few times in recent threads, and I wanted to gather some > additional info on your real world use cases. Just reply to me, and any input > is appreciated: > > 1. Does

Re: [swift-users] Should I be using more catchless do blocks?

2017-06-19 Thread Rien via swift-users
Yes. But: Only if it makes the code better. I think that “understandability engineering” is just as important as “software engineering”. Maybe more so. After all, code that we understand has a better chance of working correctly than code that follows all paradigms but once the developer is

Re: [swift-users] Decode a JSON object of unknown format into a Dictionary with Decodable in Swift 4

2017-06-18 Thread Rien via swift-users
Dang, hit send too soon. Sorry. This does not address your question, so please ignore… (foot in mouth)! Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Balancingrock Project: http://swiftfire.nl - An HTTP(S) web server framework in Swift

Re: [swift-users] Decode a JSON object of unknown format into a Dictionary with Decodable in Swift 4

2017-06-18 Thread Rien via swift-users
Are you looking for a general purpose JSON interpreter / API ? There are many of them around, and in fact I do have my own: https://github.com/Balancingrock/VJson With VJson I would write: let json = VJson.parse(… your json object…) and then access the metadata as: let buyCount = (json |

[swift-users] Generating html code, best practise?

2017-05-19 Thread Rien via swift-users
I want to generate some HTML code with Swift. Of course there are many way to do this, but I am not looking to do an "in-dept all options open” approach. Just some ‘get the html out quickly” type of thing. So I wonder, how do _you_ do this? Simply using Strings is one option, but cumbersome and

Re: [swift-users] Making Error sub-enums Equatable

2017-05-08 Thread Rien via swift-users
I’d love to know if there is a better way, but a ‘switch’ or 'if case' is the only way I know. Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Balancingrock Project: http://swiftfire.nl - A server for websites build in Swift > On

Re: [swift-users] weak self

2017-05-02 Thread Rien via swift-users
://swiftfire.nl - A server for websites build in Swift > On 01 May 2017, at 23:26, Guillaume Lessard <gless...@tffenterprises.com> > wrote: > > Hi Rien, > >> On May 1, 2017, at 08:46, Rien via swift-users <swift-users@swift.org> wrote: >> >> In m

Re: [swift-users] weak self

2017-05-01 Thread Rien via swift-users
e> >>> wrote: >>> >>>> >>>> On May 1, 2017, at 4:46 PM, Rien via swift-users <swift-users@swift.org> >>>> wrote: >>>> >>>> In my code I use a lot of queues. And (very often) I will use [weak self] >>>>

Re: [swift-users] weak self

2017-05-01 Thread Rien via swift-users
> On 01 May 2017, at 16:59, Dennis Weissmann <den...@dennisweissmann.me> wrote: > >> >> On May 1, 2017, at 4:46 PM, Rien via swift-users <swift-users@swift.org> >> wrote: >> >> In my code I use a lot of queues. And (very often) I will use [w

[swift-users] weak self

2017-05-01 Thread Rien via swift-users
In my code I use a lot of queues. And (very often) I will use [weak self] to prevent doing things when ‘self’ is no longer available. Now I am wondering: how does the compiler know that [weak self] is referenced? I am assuming it keeps a reverse reference from self to the [weak self] in order

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-28 Thread Rien via swift-users
You will need to take full control over allocation and deallocation. Here is a piece of code from my project SwifterSockets (on github, see the link in my signature) public func tipReceiverLoop( socket: Int32, bufferSize: Int, duration: TimeInterval, receiver: ReceiverProtocol?)

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-28 Thread Rien via swift-users
To address your question: https://developer.apple.com/reference/foundation/data/1779823-withunsafemutablebytes "Warning The byte pointer argument should not be stored and used outside of the lifetime of the call to the closure." Which is exactly what you are doing, hence the code is unsafe (no

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-27 Thread Rien via swift-users
> On 27 Apr 2017, at 09:54, Rick Mann <rm...@latencyzero.com> wrote: > >> >> On Apr 26, 2017, at 23:37 , Rien via swift-users <swift-users@swift.org> >> wrote: >> >> 1) When you obtain a pointer, it can no longer be ensured by the compi

Re: [swift-users] Why does withUnsafePointer(to:) require a var argument?

2017-04-27 Thread Rien via swift-users
1) When you obtain a pointer, it can no longer be ensured by the compiler that you won’t write to it. 2) A ‘let’ variable (constant) allows way more optimizations than a ‘var’. I would not be surprised if the majority of ‘let’ constants never see any memory allocation at all. Regards, Rien

Re: [swift-users] edit array

2017-04-26 Thread Rien via swift-users
Agree, though the function should probably be named something like: withEach instead of forEach. Maybe worth a proposal on evolution? Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Balancingrock Project: http://swiftfire.nl - A server

Re: [swift-users] edit array

2017-04-26 Thread Rien via swift-users
Because you are (trying) to edit a copy. To edit the value in the array itself use: array[index].number += 1 Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Balancingrock Project: http://swiftfire.nl - A server for websites build in

Re: [swift-users] Alternative to UnicodeScalar

2017-04-09 Thread Rien via swift-users
With the Array operations: append or insert var tmp: [CChar] = [0, 0] for i in 1 ... 100 { tmp.insert(0, at: 0) } Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Balancingrock Project: http://swiftfire.nl - A server for websites

Re: [swift-users] Swift 3.1 String(

2017-04-05 Thread Rien via swift-users
> On 05 Apr 2017, at 16:26, Maxim Veksler via swift-users > wrote: > > Hi, > > Swift 3.1 compiler seems to introduces a new complier warning regarding > String(describing: ) > > So this line: > Log.info("Update name for user \(fbUser)”) Log.info(“Update name for user

Re: [swift-users] Importing C system libraries

2017-03-28 Thread Rien via swift-users
I feel your pain ;-) Just embrace the dark side, it takes a little time to get used to, but chances are you won’t regret it. Btw: I still do my development in Xcode, its just that using the SPM (Swift Package Manager) and git from the command line gives a whole extra dimension to my

Re: [swift-users] Type inference of array element type

2017-03-24 Thread Rien via swift-users
Site: http://balancingrock.nl >> Blog: http://swiftrien.blogspot.com >> Github: http://github.com/Balancingrock >> Project: http://swiftfire.nl >> >> >> >> >> >>> On 24 Mar 2017, at 11:22, Rien via swift-users <swift-users@swift.org>

Re: [swift-users] Improving compilation times?

2017-03-23 Thread Rien via swift-users
l ?? "?" str += "No: \(count), HostIp: " + clientIp + " at port: " + service + "\n” Regards, Rien. > > On 23 Mar 2017, at 08:11, Rien via swift-users <swift-users@swift.org> wrote: > >> Thanks for that link, used it to track d

Re: [swift-users] Improving compilation times?

2017-03-23 Thread Rien via swift-users
Thanks for that link, used it to track down the worst compile time offender: This piece of code: public func logAddrInfoIPAddresses(_ infoPtr: UnsafeMutablePointer) -> String { let addrInfoNil: UnsafeMutablePointer? = nil var count: Int = 0 var info: UnsafeMutablePointer =

Re: [swift-users] It seems like we really need an #include preprocessor directive?

2017-03-11 Thread Rien via swift-users
> On 11 Mar 2017, at 21:12, Edward Connell via swift-users > wrote: > > Observations about difining an object > • Structs can't inherit and classes shouldn't inherit, final concrete > types should be flat Why? I always default to the position that we should do

Re: [swift-users] Generics with variable argument lists

2017-03-09 Thread Rien via swift-users
017 11:05, Rien via swift-users wrote: >> I am trying to achieve the following: >> >> enum FunctionResult { >> case success(T) >> case error(String) >> } >> >> func tester(test: (…) -> FunctionResult, onError: (String) -> T) -> T { >&

[swift-users] Generics with variable argument lists

2017-03-09 Thread Rien via swift-users
I am trying to achieve the following: enum FunctionResult { case success(T) case error(String) } func tester(test: (…) -> FunctionResult, onError: (String) -> T) -> T { … } The problem is of course the (…) that simply does not work. I would like to use this generic with a variety of

Re: [swift-users] What is the intended response to Array change notification for dependents?

2017-03-06 Thread Rien via swift-users
I don’t think there is a single answer to this. It is all highly dependant on what the application does with the info. Sometimes it will indeed be necessary to rebuild the entire gui, other times it is enough to simply insert a new table cell. Regards, Rien Site: http://balancingrock.nl Blog:

Re: [swift-users] How to optionally link swift framework into another framework

2017-03-06 Thread Rien via swift-users
The way I look at it is that Swift wants all symbols resolved when linking. C++ is probably very lenient toward full resolution, and as long as you know that a certain unresolved reference is not used, you can safely ignore the warning. Or maybe the C++ compiler is just very clever and can

Re: [swift-users] How to optionally link swift framework into another framework

2017-03-06 Thread Rien via swift-users
Well, that was a bit short… When you want to use logging, define the ACC “USE_LOGGING” in the build settings. When you don’t want to use logging, don’t define the ACC. PS: You can get my logging framework from github: https://github.com/Balancingrock/SwifterLog Regards, Rien Site:

Re: [swift-users] How to optionally link swift framework into another framework

2017-03-06 Thread Rien via swift-users
You need conditional compilation. Called “Active Compilation Conditions” in the build settings. For example define a ACC of “USE_LOGGING” Then in your code: #if USE_LOGGING import Logging #else struct Logging { func debug(message: string) {} } #endif Regards, Rien Site:

Re: [swift-users] Function conforming to a typealias

2017-02-18 Thread Rien via swift-users
. Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Balancingrock Project: http://swiftfire.nl > On 18 Feb 2017, at 12:05, Rien via swift-users <swift-users@swift.org> wrote: > > It feels a bit strange to write it like that, but

Re: [swift-users] Function conforming to a typealias

2017-02-18 Thread Rien via swift-users
ion = (Int, Bool) -> String? > > let myGreatFunc1: Function = { _ in return nil /* or whatever you need there > */ } > let myGreatFunc2: Function = { _ in return nil } > > > > > -- > Adrian Zubarev > Sent with Airmail > > Am 18. Februar 2017 um 11:47

Re: [swift-users] Function conforming to a typealias

2017-02-18 Thread Rien via swift-users
you’re trying to solve there but you could use it like this >> with closures: >> >> typealias Function = (Int, Bool) -> String? >> >> let myGreatFunc1: Function = { _ in return nil /* or whatever you need there >> */ } >> let myGreatFunc2: Function = {

[swift-users] Function conforming to a typealias

2017-02-18 Thread Rien via swift-users
I want to create a few functions that all have the same signature. The signature is defined in a typealias Is there any way to shortcut the function definition, or alternatively ensure that the function signature will always be equal to the typealias? Examplecode: typealias Mysig = (Int,

Re: [swift-users] ambiguous minus operator

2017-02-16 Thread Rien via swift-users
I don’t know about the candidates But the uptimeNanoseconds is a UInt64 and as such you should probably use substractWithOverflow. var a: UInt64 = 12 var b: UInt64 = 25 let result = UInt64.subtractWithOverflow(a, b) if result.overflow { print("Overflow") } else { let answer = result.0

Re: [swift-users] UnsafePointer to UInt64

2017-02-16 Thread Rien via swift-users
egards, Martin > >> On 16 Feb 2017, at 14:27, Rien via swift-users <swift-users@swift.org> wrote: >> >> What would be the easiest (and fastest) way to convert a pointer to an >> (unsigned)integer? >> >> Ptr -> String -> Int >> >>

[swift-users] UnsafePointer to UInt64

2017-02-16 Thread Rien via swift-users
What would be the easiest (and fastest) way to convert a pointer to an (unsigned)integer? Ptr -> String -> Int seems a bit cumbersome to me :-) Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Balancingrock Project: http://swiftfire.nl

Re: [swift-users] [swift-evolution] Plan to move swift-evolution and swift-users mailing lists to Discourse

2017-02-09 Thread Rien via swift-users
> On 09 Feb 2017, at 18:29, Cihat Gündüz via swift-evolution > wrote: > > @Jan: Your arguments are very subjective if not even insulting and derogatory > to many people who invest a lot of time and effort in crafting those things > you despise so openly. Here are

Re: [swift-users] Custom operators in a framework

2017-02-03 Thread Rien via swift-users
; >>>> I.e. I have a: >>>> >>>> infix operator &= >>>> >>>> And when I use that from another module I get “Operator is not a known >>>> binary operator” >>>> >>>> Once I repeat the

Re: [swift-users] Custom operators in a framework

2017-02-03 Thread Rien via swift-users
ttp://github.com/Balancingrock >> Project: http://swiftfire.nl >> >> >> >> >> >>> On 03 Feb 2017, at 18:14, Jordan Rose <jordan_r...@apple.com> wrote: >>> >>> Operator declarations are actually public all the time, not internal

Re: [swift-users] Swift 101: JSON or XML?

2017-02-03 Thread Rien via swift-users
I do not think there is a ‘best’ answer. I would go with JSON though. Apple’s JSON solution is fast, but it has some minor limitations and usability is not “up there”. Then again there are third party solutions, for example my own SwifterJSON single-class framework that you can download from

[swift-users] Custom operators in a framework

2017-02-03 Thread Rien via swift-users
It is possible to define custom operators in a framework, but it is not possible to assign access levels to them. As a consequence they are module internal and cannot be used outside the framework. Each project needs to redefine the custom operators in order to use them in that project. What

Re: [swift-users] SPM: how to create cocoa xcode projects?

2017-01-26 Thread Rien via swift-users
ding on a bunch of SPM packages? Rien. > >> On Jan 26, 2017, at 4:24 AM, Rien via swift-users <swift-users@swift.org> >> wrote: >> >> Just a quick question, >> >>> swift package init —type executable >> >> creates an xcode project

[swift-users] SPM: how to create cocoa xcode projects?

2017-01-26 Thread Rien via swift-users
Just a quick question, > swift package init —type executable creates an xcode project with a main.swift. I want to create a macOS cocoa based application. How is that best achieved? Or is that not supported yet? Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com

Re: [swift-users] SPM: no such module - System Library Wrapper

2017-01-26 Thread Rien via swift-users
com> wrote: > > Have a look at BlueSockets which does the same kind of thing: > > https://github.com/IBM-Swift/BlueSocket > https://github.com/IBM-Swift/BlueSSLService > > There's a wrapper around OpenSSL as well: > > https://github.com/IBM-Swift/OpenSSL.git > >

Re: [swift-users] Casting function pointers

2017-01-25 Thread Rien via swift-users
Github: http://github.com/Balancingrock Project: http://swiftfire.nl > On 25 Jan 2017, at 19:37, Joe Groff <jgr...@apple.com> wrote: > > >> On Jan 25, 2017, at 1:23 AM, Rien via swift-users <swift-users@swift.org> >> wrote: >> >> I have a case

Re: [swift-users] Callback in Swift

2017-01-25 Thread Rien via swift-users
> On 25 Jan 2017, at 10:33, John Brownie wrote: > > Thanks, that does it for me, though I had to qualify the Unmanaged with a > type in the first part. > > Rien wrote: >> For the context I passed in: >> >>

Re: [swift-users] Casting function pointers

2017-01-25 Thread Rien via swift-users
tp://github.com/Balancingrock Project: http://swiftfire.nl > On 25 Jan 2017, at 10:23, Rien via swift-users <swift-users@swift.org> wrote: > > I have a case where a callback has the following signature: > > @convention(c) (_ ssl: OpaquePointer?, _ num: UnsafeMutablePointer

[swift-users] Casting function pointers

2017-01-25 Thread Rien via swift-users
I have a case where a callback has the following signature: @convention(c) (_ ssl: OpaquePointer?, _ num: UnsafeMutablePointer?, _ arg: UnsafeMutableRawPointer?) -> Int32 But to install this callback I have to use a c-function with this signature: SSL_CTX_callback_ctrl (OpaquePointer!, Int32,

[swift-users] SPM: Specify search paths?

2017-01-24 Thread Rien via swift-users
I am still running into walls with SPM. Is there a way to specify the header and library search paths when using the Swift Package Manager? Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Balancingrock Project: http://swiftfire.nl

Re: [swift-users] SPM & Library with bridging header

2017-01-21 Thread Rien via swift-users
t; >> And pkgConfig cannot be used on a non-system module. >> >> But without specifying the import search path, SPM cannot compile the c-code. >> >> Any suggestions? >> >> Regards, >> Rien >> >> Site: http://balancingrock.nl >>

Re: [swift-users] enum compare

2017-01-21 Thread Rien via swift-users
Oh, I am not using the correct terminology, sorry. Enum’s don’t have “instances” right? Anyhow, I guess you get my drift… Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Swiftrien Project: http://swiftfire.nl > On 21 Jan 2017, at

Re: [swift-users] enum compare

2017-01-21 Thread Rien via swift-users
The “==“ operation can only compare concrete instances of the enum. With “type == ACType.other” the right side is not an instance. as the associated value is missing. Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Swiftrien Project:

Re: [swift-users] SPM & Library with bridging header

2017-01-21 Thread Rien via swift-users
20 Jan 2017, at 19:48, Rien via swift-users <swift-users@swift.org> wrote: > > I may be missing something here, so please bear with me... > > The client of the lib only has to see the headers that describe the lib, not > the headers of the files that were used to crea

[swift-users] Migrating to SPM, best practise?

2017-01-18 Thread Rien via swift-users
I have a small sockets based framework on Github (SwifterSockets). It was created before SPM existed. The next update is planned, and I want to move to SPM. 1) How to create a package around the old xcode project? 2) I am unsure how to move from the old git structure to the new. What would be

Re: [swift-users] C-function not found by linker

2017-01-11 Thread Rien via swift-users
://github.com/Swiftrien Project: http://swiftfire.nl > On 11 Jan 2017, at 10:28, Rien via swift-users <swift-users@swift.org> wrote: > > My project uses openSSL and that works fine. > > I needed one specific function that cannot be accessed from Swift directly, > so I created

Re: [swift-users] Exclamation mark's in swift parameter listings?

2017-01-10 Thread Rien via swift-users
://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Swiftrien Project: http://swiftfire.nl > On 10 Jan 2017, at 18:14, Joe Groff <jgr...@apple.com> wrote: > > >> On Jan 9, 2017, at 11:19 PM, Rien via swift-users <swift-users@swift.org> >> w

Re: [swift-users] getResourceValue

2017-01-06 Thread Rien via swift-users
Thanks Rod, very enlightening! Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Swiftrien Project: http://swiftfire.nl > On 06 Jan 2017, at 15:19, Rod Brown wrote: > > >> On 7 Jan 2017, at 12:50 am, Rien

Re: [swift-users] getResourceValue

2017-01-06 Thread Rien via swift-users
Hmm, that is interesting to know. I had not realised that URL is in fact NOT a NSURL but a new type that is based on NSURL (and can be toll-free bridged I assume?). I also presume that the same is true for Data/NSData, Date/NSDate etc? (Failure on my part, as I did of course know that the .path

Re: [swift-users] getResourceValue

2017-01-06 Thread Rien via swift-users
URL is the same as NSURL in Swift 3 Foundation -> NSURL -> getResourceValue. If you use xcode, open up the Help -> Documentation and API reference The do a search for getResourceValue. Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github:

Re: [swift-users] getResourceValue

2017-01-05 Thread Rien via swift-users
What is your real question? Obviously the doc says that this is fine, so what are you asking? what is your problem? Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Swiftrien Project: http://swiftfire.nl > On 05 Jan 2017, at 20:36,

Re: [swift-users] Compiler should issue a warning when a subclass implementation with default values matches a parent implementation without them

2017-01-04 Thread Rien via swift-users
As you know. there is no ambiguity, no warnings needed. (The parameter is part of the identifier of the function) Imo, this request falls into the category “do as I think, not as I say”. That is a discussion without end. Personally I am against ANY warnings of this kind. The reason is that I

[swift-users] UnsafePointer and C-String

2017-01-03 Thread Rien via swift-users
The documentation at https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html shows that it is possible to use String where an UnsafePointer is needed. API calls to C that need a char* are translated to UnsafePointer. It follows that

Re: [swift-users] Weird protocol behaviour.

2016-12-30 Thread Rien via swift-users
M, Howard Lovatt via swift-users >>> <swift-users@swift.org> wrote: >>> >>> I suspect a compiler bug since A is a P. The equivalent in Java works: >>> >>> interface P {} >>> class X implements P {} >>> >>> void foo(A

Re: [swift-users] Using 'SomeProtocol' as a concrete type conforming to protocol 'SomeProtocol' is not supported

2016-12-29 Thread Rien via swift-users
As to the why question: (just guessing here) By the time the compiler want to know what type will be in the array, it cannot do so. The enum is a generic and thus without full type information (it only has partial type information). Regards, Rien Site: http://balancingrock.nl Blog:

Re: [swift-users] Weird protocol behaviour.

2016-12-23 Thread Rien via swift-users
ired. IMO it’s a bug and `:` >> should be fixed to include the root type, whether or not that requires a >> discussion on -evolution. >> >>> On Dec 22, 2016, at 2:17 PM, Howard Lovatt via swift-users >>> <swift-users@swift.org> wrote: >>> >

Re: [swift-users] Implicitly capture a mutating self

2016-12-16 Thread Rien via swift-users
, at 02:49, Zhao Xin <owe...@gmail.com> wrote: >> >> What is the type of self? If it is a class, try [unowned self]. >> >> Zhaoxin >> >> >> >> >> >> >> On Fri, Dec 16, 2016 at 4:33 PM, Rien via swift-users >> <sw

Re: [swift-users] Implicitly capture a mutating self

2016-12-16 Thread Rien via swift-users
How about using: UnsafeMutablePointer ? Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Swiftrien Project: http://swiftfire.nl > On 16 Dec 2016, at 09:10, Richard Wei via swift-users > wrote: > > Capturing

Re: [swift-users] Overload Resolution of Binary Operators

2016-11-14 Thread Rien via swift-users
I seem to remember that while it is possible to define, the compiler will yield an error if you try to use the functions (“cannot resolve”). Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Swiftrien Project: http://swiftfire.nl > On

Re: [swift-users] Details of defer statement in Swift

2016-11-09 Thread Rien via swift-users
The manual says this: https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html A defer statement is used for executing code just before transferring program control outside of the scope that the defer statement appears in. The scope

Re: [swift-users] Understanding pass-by-value

2016-11-04 Thread Rien via swift-users
> On 04 Nov 2016, at 13:59, Ryan Lovelett via swift-users > wrote: > > struct Foo { > init(from buffer: Data) { > bar = integer(withBytes: Array(buffer[4..<6])) > baz = integer(withBytes: Array(buffer[6..<8])) > ... > } > > let d = Data(count: Int(3e+8)) >

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

2016-11-04 Thread Rien via swift-users
> On 03 Nov 2016, at 23:58, Manfred Schubert via swift-users > wrote: > > Am 03.11.2016 um 15:41 schrieb Rien : >> >> Ah, but that is not the case. >> >> It is important to differentiate between the “gateway” to the memory and the >> memory area

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

2016-11-03 Thread Rien via swift-users
> On 03 Nov 2016, at 15:16, Manfred Schubert via swift-users > wrote: > > >> Am 02.11.2016 um 18:37 schrieb Rien : >> var rawPtr = UnsafeMutableRawPointer.allocate(bytes: 2, alignedTo: 0) var widePtr = rawPtr.bindMemory(to:

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

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

2016-11-01 Thread Rien via swift-users
The way I understand it, it prepares a memory structure that refers to the ‘raw memory’ such that it can be used to access the referenced memory according to the type ‘bound’ to. Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github:

Re: [swift-users] Set-uniqueness of instances with distinct hashValue

2016-10-23 Thread Rien via swift-users
If you change the “==“ function to: func == (lhs: X, rhs: X) -> Bool { return (lhs.x == rhs.x) && (lhs.hashValue == rhs.hashValue) } then the example works as expected. Apple says this: “A hash value, provided by a type’s hashValue property, is an integer that is the same for any two

Re: [swift-users] Segmentation fault: 11 after updating codebase to Swift 3.0

2016-10-21 Thread Rien via swift-users
I had a similar problem with Xcode 7.2. The work around I found then was to remove all source files from the project in the “target membership” except for the main.swift file. Then compile again, which will (of course) fail with normal errors. Then I added the files back in, presto, no more