[swift-users] UnsafeMutablePointer in structs

2016-05-20 Thread Adrian Zubarev via swift-users
Can I put an UnsafeMutablePointer inside a struct and destroy deallocate correctly without nesting a class which has `deinit`? I’m not sure how to check this. --  Adrian Zubarev Sent with Airmail ___ swift-users mailing list swift-users@swift.org https

[swift-users] UnsafeMutablePointer vs. UnsafeMutablePointer

2016-05-21 Thread Adrian Zubarev via swift-users
I played around with UnsafeMutablePointer and realized one behavior: let pString = UnsafeMutablePointer.alloc(1) pString.initialize("test") pString.predecessor().memory // will crash ax expected pString.predecessor() == pString.advancedBy(-1) // true pString.destroy() pString.dealloc(1) where let

Re: [swift-users] UnsafeMutablePointer vs. UnsafeMutablePointer

2016-05-21 Thread Adrian Zubarev via swift-users
, Dmitri Gribenko (griboz...@gmail.com) schrieb: Hi Adrian, On Sat, May 21, 2016 at 1:48 AM, Adrian Zubarev via swift-users wrote: > I played around with UnsafeMutablePointer and realized one behavior: > > let pString = UnsafeMutablePointer.alloc(1) > pString.init

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

2016-05-26 Thread Adrian Zubarev via swift-users
I’ve got one more questions about Unsafe(Mutable)Pointer. I know that I’m able to access memory that might not belong to me. My question is: Can I trust these functions that they will return a pointer to some memory when I allocate more than one object AND when I’m moving only inside that range

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

2016-05-26 Thread Adrian Zubarev via swift-users
ons or do I miss something here?! --  Adrian Zubarev Sent with Airmail Am 26. Mai 2016 bei 19:14:41, Andrew Trick (atr...@apple.com) schrieb: On May 26, 2016, at 9:59 AM, Adrian Zubarev via swift-users wrote: I’ve got one more questions about Unsafe(Mutable)Pointer. I know that I’m able

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

2016-05-26 Thread Adrian Zubarev via swift-users
It's also not clear sometimes exactly what "out of bounds" means - for example, you might have a big chunk of memory representing an array, and then you take a pointer to only part of that memory, representing a slice of the array. In this case you can write "out of bounds" of the slice, but the

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

2016-06-01 Thread Adrian Zubarev via swift-users
I’d like to talk about your personal coding styles in swift for its access control. Remember these variable names like __magic or _spell or even garbage_? Sure swift solves the synthesize problem but there might be old habits that let us write such code. Here are some examples: internal _name

Re: [swift-users] UnsafeMutablePointer vs. UnsafeMutablePointer

2016-06-01 Thread Adrian Zubarev via swift-users
Zubarev via swift-users wrote: I played around with UnsafeMutablePointer and realized one behavior: let pString = UnsafeMutablePointer.alloc(1) pString.initialize("test") pString.predecessor().memory // will crash ax expected pString.predecessor() == pString.advancedBy(-1) // true pStri

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

2016-06-01 Thread Adrian Zubarev via swift-users
A little bit off-topic: Is there any way to create autocompletion shortcuts in Xcode that will show only private, internal or both values of an instance? class Foo { private var integer: Int = 0 internal var string: String = "foo" internal func boo() {} } let instance = Foo() instan

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

2016-06-01 Thread Adrian Zubarev via swift-users
developers. -- E On Jun 1, 2016, at 10:02 AM, Adrian Zubarev via swift-users wrote: I’d like to talk about your personal coding styles in swift for its access control. Remember these variable names like __magic or _spell or even garbage_? Sure swift solves the synthesize problem but there m

[swift-users] When does `Data.init?(capacity:)` fail?

2016-06-17 Thread Adrian Zubarev via swift-users
Hello there, I’m trying to optimize my code and reduce copying from different buffers into a new one. I thought I just create a Data value with enough capacity and write directly into it. My problem is that Data.init?(capacity:) can fail, but why and when? Can someone explain this behavior to m

Re: [swift-users] When does `Data.init?(capacity:)` fail?

2016-06-19 Thread Adrian Zubarev via swift-users
:38 AM Adrian Zubarev via swift-users wrote: Hello there, I’m trying to optimize my code and reduce copying from different buffers into a new one. I thought I just create a Data value with enough capacity and write directly into it. My problem is that Data.init?(capacity:) can fail, but why and

Re: [swift-users] [swift-evolution] Tuple

2016-07-20 Thread Adrian Zubarev via swift-users
CC to the right place. --  Adrian Zubarev Sent with Airmail Am 20. Juli 2016 um 10:08:13, Fabian Ehrentraud via swift-evolution (swift-evolut...@swift.org) schrieb: Hi, I have a problem with tuple parameter types in a closure. Is this a language restriction or a bug in the Swift compiler? I

[swift-users] open/public protocol with not overridable default implementation in the future?

2016-09-16 Thread Adrian Zubarev via swift-users
I always wanted a way to make some protocol default implementations not overridable. Now Swift 3 got open vs. public behavior for classes. (Hopefully the inconsistency will be fixed soon and we’ll get open protocols as well.) Imagine this scenario with open/public protocols. // Module A // `ope

[swift-users] Problem with COW optimization

2016-09-18 Thread Adrian Zubarev via swift-users
Dear Swift community, currently I’m building a value type XML library which is baked behind the scene with a reference type to manage graph traversing between nodes. I also like to COW optimize the xml graph, but I run into one single problem atm. Image this xml tree: It’s just a root e

Re: [swift-users] Mutex/queue access in Swift 3

2016-09-23 Thread Adrian Zubarev via swift-users
Whops sry wrong receiver mail. :/ My bad. --  Adrian Zubarev Sent with Airmail Am 23. September 2016 um 17:51:44, Adrian Zubarev (adrian.zuba...@devandartist.com) schrieb: Do you care about the order in which your queue is filled? Do you have multiple queues - I’m asking because your serial q

[swift-users] RawRepresentable bug or intended?

2016-09-28 Thread Adrian Zubarev via swift-users
struct B : RawRepresentable { let rawValue: Int // init?(rawValue: Int) { // // self.rawValue = rawValue // } static let c: B = B(rawValue: 0) static let d: B = B(rawValue: 1) } It seems to me that the memberwise initializer init(rawValue: Int) ignores the fail

Re: [swift-users] Binary Operator '??' cannot be applied to operands of type 'T?' and 'Never'

2016-10-06 Thread Adrian Zubarev via swift-users
I’ve build a custom operator for this: https://gist.github.com/DevAndArtist/dad641ee833e60b02fd1db2dbb488c6a infix operator ?! : NilCoalescingPrecedence func ?!(optional: T?, noreturn: @autoclosure () -> Never) -> T { switch optional { case .some(let value): return value case .non

Re: [swift-users] [swift-evolution] [Question] Types of functions

2016-10-06 Thread Adrian Zubarev via swift-users
We should move this thread to swift-users. Here is something that I just tried: func foo(_: Int, _: Int) {} func boo(_: (Int, Int)) {} type(of: foo) == type(of: boo) //=> true ; (((Int, Int)) -> ()).Type let tuple = (0, 42) foo(tuple) // Tuple splat was removed => Error boo(tuple) // Expected =>

Re: [swift-users] [swift-evolution] [Question] Types of functions

2016-10-06 Thread Adrian Zubarev via swift-users
Maybe :D No actually I had to test an iOS app feature depending on that date but forget to reset the system date and time. --  Adrian Zubarev Sent with Airmail Am 6. Oktober 2016 um 20:38:53, Vladimir.S (sva...@gmail.com) schrieb: (Adrian, are you from the future? ;-)  ___

Re: [swift-users] ideas to remove NSCoding as requirement in UIView subclasses

2016-10-08 Thread Adrian Zubarev via swift-users
This is a wrong place to ask. This topic is part of the iOS SDK from Apple not part of Swift itself or libraries like Foundation. -- Adrian Zubarev Sent with Airmail Am 8. Oktober 2016 um 18:32:50, Lou Zell via swift-users (swift-users@swift.org(mailto:swift-users@swift.org)) schrieb: > > O

Re: [swift-users] find std lib doc

2016-10-12 Thread Adrian Zubarev via swift-users
It’s not hidden. https://developer.apple.com/ Develop API Reference Swift Standard Library Profit https://developer.apple.com/reference/swift --  Adrian Zubarev Sent with Airmail Am 12. Oktober 2016 um 11:55:17, J.E. Schotsman via swift-users (swift-users@swift.org) schrieb: Is it just me, o

Re: [swift-users] find std lib doc

2016-10-12 Thread Adrian Zubarev via swift-users
You could also fallback to http://swiftdoc.org. ;) --  Adrian Zubarev Sent with Airmail Am 12. Oktober 2016 um 17:01:48, Jon Shier via swift-users (swift-users@swift.org) schrieb: I’m guessing you only came to Apple’s developer environment with Swift? (If not I apologize.) The searchability

[swift-users] Custom little/big endian data structure.

2016-10-30 Thread Adrian Zubarev via swift-users
Hi there, is there actually a way to build a custom data structure that will automatically be converted to little/big endian on a little/big endian system, just like (U)Int16/32/64 do? I could build as a workaround a mechanism that will do that for me, but I’m curious if this is possible with

Re: [swift-users] Custom little/big endian data structure.

2016-11-01 Thread Adrian Zubarev via swift-users
Hi Chris, thank you for your answer. I can’t wait for property behaviors, it’s going to be such a powerful feature. :) --  Adrian Zubarev Sent with Airmail Am 1. November 2016 um 18:34:55, Chris Lattner (clatt...@apple.com) schrieb: On Oct 30, 2016, at 12:50 PM, Adrian Zubarev via swift

[swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
Hi there, I just can’t get my head around mutable views and COW. Here is a small example: final class Storage { var keys: [String] = [] var values: [Int] = [] } public struct Document { var _storageReference: Storage public init() { self._stor

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
nowned` for. If you can't grantee that. You should use `weak` and check it with `if let` or `if foo == nil` Zhaoxin On Fri, Nov 18, 2016 at 8:05 PM, Adrian Zubarev via swift-users wrote: Hi there, I just can’t get my head around mutable views and COW. Here is a small example: final cl

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
st use it directly, this is what `unowned` for. If you can't grantee that. You should use `weak` and check it with `if let` or `if foo == nil` Zhaoxin On Fri, Nov 18, 2016 at 8:05 PM, Adrian Zubarev via swift-users wrote: Hi there, I just can’t get my head around mutable views and COW.

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
can't grantee that. You should use `weak` and check it with `if let` or `if foo == nil` Zhaoxin On Fri, Nov 18, 2016 at 8:05 PM, Adrian Zubarev via swift-users wrote: Hi there, I just can’t get my head around mutable views and COW. Here is a small example: final class Storage {

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
s. Just use it directly, this is what `unowned` for. If you can't grantee that. You should use `weak` and check it with `if let` or `if foo == nil` Zhaoxin On Fri, Nov 18, 2016 at 8:05 PM, Adrian Zubarev via swift-users wrote: Hi there, I just can’t get my head around mutable views and C

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
via swift-users wrote: Hi there, I just can’t get my head around mutable views and COW. Here is a small example: final class Storage { var keys: [String] = [] var values: [Int] = [] } public struct Document { var _storageReference: Storage public init

Re: [swift-users] Problem with mutable views and COW

2016-11-18 Thread Adrian Zubarev via swift-users
, Karl wrote: On 18 Nov 2016, at 13:05, Adrian Zubarev via swift-users wrote: Hi there, I just can’t get my head around mutable views and COW. Here is a small example: final class Storage { var keys: [String] = [] var values: [Int] = [] } public struct Document { var

Re: [swift-users] Bool to Int

2016-11-21 Thread Adrian Zubarev via swift-users
In general this is a correct behaviour, because literals in Swift are untyped. Int does not have any initializer for a Bool so the compiler tries to find a type that might conforms to ExpressibleByBooleanLiteral for all possible initializer of Int (Int.init(_: TYPE)). This resolution decides to

Re: [swift-users] Bool to Int

2016-11-21 Thread Adrian Zubarev via swift-users
@swift.org) schrieb: This is so confusing. "Literals are untyped", but there’s a “BooleanLiteral”, which is obviously of type Boolean. -Kenny > On Nov 21, 2016, at 2:49 AM, Adrian Zubarev via swift-users > wrote: > > In general this is a correct behaviour, because

Re: [swift-users] Existentials in Swift

2016-11-21 Thread Adrian Zubarev via swift-users
You’re welcome. If you want to learn how Metatypes and Existential Metatypes work in Swift, take a look at our proposal where we discuss the current situation and how we want these types to be in Swift. Link When learning about existential types, our proposal might be a little bit hard to foll

Re: [swift-users] Bool to Int

2016-11-21 Thread Adrian Zubarev via swift-users
Where is your problem here? It’s simple and easy ;) extension Integer { init(_ boolean: Bool) { self = boolean ? 1 : 0 } } Int(10 > 4) UInt32(1 <= 2) --  Adrian Zubarev Sent with Airmail Am 22. November 2016 um 00:54:47, Rick Mann via swift-users (swift-users@

Re: [swift-users] Extending Arrays of specific type, and specialization

2016-11-22 Thread Adrian Zubarev via swift-users
It’s already fixed for Swift 3.1. Here is the change log. --  Adrian Zubarev Sent with Airmail Am 22. November 2016 um 01:32:42, Rick Mann via swift-users (swift-users@swift.org) schrieb: My googling is not turning up an answer that works in Xcode 8.1. I'd like to do this: import Accelera

Re: [swift-users] Bool to Int

2016-11-22 Thread Adrian Zubarev via swift-users
Want to see some real magic? struct A : _ExpressibleByBuiltinIntegerLiteral { init(_builtinIntegerLiteral value: _MaxBuiltinIntegerType) {} } struct B : ExpressibleByIntegerLiteral { init(integerLiteral value: A) { print(type(of: value)) } } let b: B = 4

Re: [swift-users] [swift-evolution] [Pitch] Numeric enum cases

2016-11-23 Thread Adrian Zubarev via swift-users
The general idea of allowing this came from another thread that I started: [swift-evolution] [Discussion] Parameter ‘vector’ keyword vs. triple dot prefix for variadic generics Another real world use case I could think of is to put numeric error codes inside an enum. enum TCPSocketErrorCode :

[swift-users] Is there any talk about overloading enum cases with associated values?

2016-11-25 Thread Adrian Zubarev via swift-users
I’m trying to find any talk on the evolution list about the overloading of enum cases with associated values. Has this already been discussed? Any technical reasons why we don’t have this already? Anyone else would want this feature? enum MyEnum { case a. // <—\ //

[swift-users] How to rewrite this snippet without `existentials`?

2016-12-02 Thread Adrian Zubarev via swift-users
Existentials are still missing in the language. Any advice how to rewrite the code so it still would do its job under the hood? protocol Proto : class { // `A` is a generic type and therefore should stay as an associatedtype associatedtype A func performWith(_ a: A) } final class

Re: [swift-users] How to rewrite this snippet without `existentials`?

2016-12-02 Thread Adrian Zubarev via swift-users
Thanks, that works party as needed but I just realize this main idea here is exactly an example where one would need generic protocols, because I cannot overload the function with associatedtype as I’d need it. --  Adrian Zubarev Sent with Airmail Am 2. Dezember 2016 um 13:33:37, Tino Heth (2

Re: [swift-users] How to rewrite this snippet without `existentials`?

2016-12-02 Thread Adrian Zubarev via swift-users
For anyone interested. The correct idea should go into this direction one day: public class Router { open protocol Connection : class { var router: Router { get set } func performWith(_ value: T) } var _connections: [Connection] = [] public typeali

Re: [swift-users] Bug? Bad behaviour?

2016-12-02 Thread Adrian Zubarev via swift-users
Can you provide more details like what type all of these instances have. It’s hard to follow what exactly you’re doing there. --  Adrian Zubarev Sent with Airmail Am 2. Dezember 2016 um 19:28:20, Maury Markowitz via swift-users (swift-users@swift.org) schrieb: Check out this line of code: i

Re: [swift-users] Documentation for Linux-based Swift Development Sought

2016-12-19 Thread Adrian Zubarev via swift-users
'.epub' extension is not an iBooks exclusive ;) It's an e-book. Find yourself a capable reader :) -- Adrian Zubarev Sent with Airmail Am 19. Dezember 2016 um 17:43:22, Steven Harms via swift-users (swift-users@swift.org(mailto:swift-users@swift.org)) schrieb: > > Hi, > > I've been playing

Re: [swift-users] Weird protocol behaviour.

2016-12-23 Thread Adrian Zubarev via swift-users
What are you trying to solve here? Do you heavily rely on what A can be? Can’t you just write func foo(_ x: P) {} (here P is an existential like [in some future] Any)?! AnyObject is for classes, but you’d get the same result changing X to a class ;) If you want scratch the surface of what happ

Re: [swift-users] Weird protocol behaviour.

2016-12-23 Thread Adrian Zubarev via swift-users
I assume when we get existentials, your problem could be solved like this: protocol P {} class X: P {} func foo(_ x:A) {} func bar() { let x = X() as Any foo(x) } Here A will be Any which conforms to P and makes the compiler happy. let c: P = … here is P and existential like (future) An

Re: [swift-users] Weird protocol behaviour.

2016-12-23 Thread Adrian Zubarev via swift-users
Whoops, wait a second. Correcting my self here. Copied the wrong url. Here is the proposal I meant. LINK --  Adrian Zubarev Sent with Airmail Am 23. Dezember 2016 um 09:57:49, Adrian Zubarev (adrian.zuba...@devandartist.com) schrieb: What are you trying to solve here? Do you heavily rely on

Re: [swift-users] Weird protocol behaviour.

2016-12-23 Thread Adrian Zubarev via swift-users
= X() as P`. It is in line ` foo(x)`, `x's type is P`, but `foo(:)` request a parameter type of `A`, not `P`. `func foo(_ x:A) {}` means, `x` must be `A`, and `A` conforms `P`. But not all `P`s are `A`. Zhaoxin On Fri, Dec 23, 2016 at 5:26 PM, Adrian Zubarev via swift-users wrote: Whoops,

Re: [swift-users] Strange Error about Default values

2017-01-18 Thread Adrian Zubarev via swift-users
Computed properties do not have any default values. That said, you can only use didSet or willSet on properties like yours to observe them or remove the default value from the computed property completely to use get and set. --  Adrian Zubarev Sent with Airmail Am 18. Januar 2017 um 15:06:16,

Re: [swift-users] default struct initializer internal even if class declared public

2017-01-18 Thread Adrian Zubarev via swift-users
I feel like I’ve seen this discussion somewhere on the mailing list before. If I remember correctly or it could be only me, this behavior is by design, because you don’t want to open your API implicitly to everyone. Internally it won’t hurt your module, but only allow you to write less code and

Re: [swift-users] default struct initializer internal even if class declared public

2017-01-18 Thread Adrian Zubarev via swift-users
to be explicit about what you want to expose publicly outside of your module. On Wed, Jan 18, 2017 at 8:40 AM Adrian Zubarev via swift-users wrote: I feel like I’ve seen this discussion somewhere on the mailing list before. If I remember correctly or it could be only me, this behavior is by

Re: [swift-users] Why this string not work. Any and Optionals in dictionary

2017-01-23 Thread Adrian Zubarev via swift-users
There is no universal `nil`. `nil` is typed. That said think of `nil` as a shorthand form for `Optional.none` -- Adrian Zubarev Sent with Airmail Am 23. Januar 2017 um 11:24:18, Седых Александр via swift-users (swift-users@swift.org(mailto:swift-users@swift.org)) schrieb: > > Hello. > I

Re: [swift-users] How do I word wrap a UIButton title in code?

2017-01-27 Thread Adrian Zubarev via swift-users
If I remember correctly the property on the UIButton is called `.lineBreakMode`, which accepts an enum. -- Adrian Zubarev Sent with Airmail Am 28. Januar 2017 um 00:46:18, Mutlu Qwerty via swift-users (swift-users@swift.org(mailto:swift-users@swift.org)) schrieb: > > > How do I make

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

2017-02-18 Thread Adrian Zubarev via swift-users
Not sure what 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 = { _ in return nil } --  Adrian Zubarev Sent with

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

2017-02-18 Thread Adrian Zubarev via swift-users
You’re welcome. I don’t think there is a better way of doing that. However you can build some wrappers with some shortcuts. func createInstance(of _: T.Type, _ istance: T) -> T { return istance } let myGreatFunc1 = createInstance(of: Function.self) { return "\($0) \($1)" // O

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

2017-02-18 Thread Adrian Zubarev via swift-users
Typo, should be instance not istance. --  Adrian Zubarev Sent with Airmail Am 18. Februar 2017 um 12:16:34, Adrian Zubarev (adrian.zuba...@devandartist.com) schrieb: You’re welcome. I don’t think there is a better way of doing that. However you can build some wrappers with some shortcuts. f

Re: [swift-users] type casting for Dictionaries keys

2017-03-23 Thread Adrian Zubarev via swift-users
It's because AnyHashable is not an existential like Any but a value type (I believe it was a struct) which erases the type restriction from your Hashable type. Simply look up AnyHashable. -- Adrian Zubarev Sent with Airmail Am 23. März 2017 um 12:07:16, Седых Александр via swift-users (swi

Re: [swift-users] Protocol composition results in EXC_BAD_ACCESS

2017-04-03 Thread Adrian Zubarev via swift-users
Why do you cast against an existential in first place? This solves the given example: protocol Something {} protocol IntContainer { var ints: [Int] { get set } } func processSomething(_ state: Something) { if let intContainer = state as? IntContainer { print(intContainer.ints)

Re: [swift-users] typealias for Generic in Generic

2017-04-04 Thread Adrian Zubarev via swift-users
R is a non generic type, because the generic part is set to T, that’s why R() works. Otherwise you could create typealias Q = Сarriage and use it like this Q() --  Adrian Zubarev Sent with Airmail Am 4. April 2017 um 19:25:45, Седых Александр via swift-users (swift-users@swift.org) schrieb:

Re: [swift-users] Xcode Windows

2017-04-13 Thread Adrian Zubarev via swift-users
I’m confused, what exactly are you trying to solve? A single view application without the main Storyboard? If that’s the case, take a look at my answer here: http://stackoverflow.com/a/43304755/4572536 Stackoverflow is a better place for such questions. This list is about pure Swift. ;) -- 

Re: [swift-users] UIview frame and bounds properties

2017-04-27 Thread Adrian Zubarev via swift-users
First of all, the swift-user list is mainly for Swift related question, which are not related to other frameworks like UIKit. You might find a better answer at Apple developer forums or on stackoverflow. ;) Second, this question is too general and not easy to answer without any code of yours. W

Re: [swift-users] UIview frame and bounds properties

2017-04-27 Thread Adrian Zubarev via swift-users
Have you tried using self.? It’s a good practice to always using self. to avoid issues where the compiler might use other globally available variables/constants functions. --  Adrian Zubarev Sent with Airmail Am 27. April 2017 um 19:28:42, Mohamed Salah via swift-users (swift-users@swift.org

Re: [swift-users] weak self

2017-05-01 Thread Adrian Zubarev via swift-users
Not answering the questions, but sharing a neat trick. [weak self] in guard let `self` = self else { return } self.foo() // strong self :) --  Adrian Zubarev Sent with Airmail Am 1. Mai 2017 um 16:46:33, Rien via swift-users (swift-users@swift.org) schrieb: In my code I use a lot of queues.

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

2017-05-11 Thread Adrian Zubarev via swift-users
I don’t think this is the answer that was asked for. I bet it’s more a technical question from the internal point of of view. --  Adrian Zubarev Sent with Airmail Am 11. Mai 2017 um 18:59:58, Zhao Xin via swift-users (swift-users@swift.org) schrieb: In Swift, you use `static in struct and en

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

2017-05-11 Thread Adrian Zubarev via swift-users
Have you read closely the bug issue before posting your answer? --  Adrian Zubarev Sent with Airmail Am 11. Mai 2017 um 19:05:13, Zhao Xin (owe...@gmail.com) schrieb: No. I think it is just a compromise. Zhaoxin On Fri, May 12, 2017 at 1:01 AM, Adrian Zubarev wrote: I don’t think this is t

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

2017-05-11 Thread Adrian Zubarev via swift-users
Furthermore: In a class declaration, the static keyword has the same effect as marking the declaration with both the class and final declaration modifiers. Source. --  Adrian Zubarev Sent with Airmail Am 11. Mai 2017 um 19:07:53, Austin Zheng (austinzh...@gmail.com) schrieb: `class` and `sta

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

2017-05-11 Thread Adrian Zubarev via swift-users
Don’t worry, help is always appreciated ;) Next time take another minute before acting to fast. --  Adrian Zubarev Sent with Airmail Am 11. Mai 2017 um 19:19:46, Zhao Xin (owe...@gmail.com) schrieb: You are right. I was wrong. Thank you. Zhaoxin On Fri, May 12, 2017 at 1:07 AM, Austin Zheng

Re: [swift-users] swift 4.0 "swift-version 4" errors with "type(of:"

2017-05-21 Thread Adrian Zubarev via swift-users
Well, I think it’s a step forward by making type(of:) *like* a stdlib function. Now we need to change .Type and .Protocol syntax to something like Type, AnyType and also fix the way it behaves in a generic context to finally open up Type for custom type names. This should also help removing .sel

Re: [swift-users] Applying MVC pattern to iOS Swift apps

2017-06-23 Thread Adrian Zubarev via swift-users
Well you are right this is not the right place for such questions, because this mailing list is about pure Swift topics. Think about MVC as MVVM where M = M, V = V and C = VM. Don't get confused by the `Controller` suffix, especially there is no `ViewController` suffix, because it always

Re: [swift-users] Is "lazy let" on the schedule anywhere?

2017-06-26 Thread Adrian Zubarev via swift-users
I myself highly want lazy constants (I’m tired of writing something like file private private(set) lazy var propertyName: ReferenceType just to hide the setter from the rest of the codebase), but I don’t think this will ever happen in Swift, at least not as an improvement for the lazy keyword it

Re: [swift-users] the pain of strings

2017-06-30 Thread Adrian Zubarev via swift-users
let longString = "1234567890" print(longString.suffix(2)) // prints "90" --  Adrian Zubarev Sent with Airmail Am 30. Juni 2017 um 23:45:01, David Baraff via swift-users (swift-users@swift.org) schrieb: I know, I’ve read tons about about this. I sympathize. Unicode, it’s all very complex. But

Re: [swift-users] the pain of strings

2017-06-30 Thread Adrian Zubarev via swift-users
This looks way better than the subscript in Python and 1000 times better than your example. It might be a good idea to look up possible API first before writing such ugly long lines. I mean they get the job done, but just why so complicated? :( --  Adrian Zubarev Sent with Airmail Am 1. Juli

Re: [swift-users] the pain of strings

2017-06-30 Thread Adrian Zubarev via swift-users
Well you’ve mentioned Swift 4 in your original post, therefore I provided a solution using Swift 4. It’s returning a view called `Substring`. --  Adrian Zubarev Sent with Airmail Am 1. Juli 2017 um 00:38:42, David Baraff (davidbar...@gmail.com) schrieb: I’m sorry, but I don’t see suffix() as a

Re: [swift-users] the pain of strings

2017-06-30 Thread Adrian Zubarev via swift-users
The best docs you can get without Xcode I know about is this one here:  https://developer.apple.com/documentation/swift/string In Swift 4 a String will yet again become a collection type. --  Adrian Zubarev Sent with Airmail Am 1. Juli 2017 um 02:57:05, David Baraff (davidbar...@gmail.com) schr

Re: [swift-users] the pain of strings

2017-06-30 Thread Adrian Zubarev via swift-users
Plus if you want to play with Swift 4 without running a toolchain or the new Xcode you can do it in your browser: https://swift.sandbox.bluemix.net/#/repl Just change that repl to Swift 4. --  Adrian Zubarev Sent with Airmail Am 1. Juli 2017 um 03:02:38, Adrian Zubarev (adrian.zuba...@devandar

Re: [swift-users] did i just imagine tuples were going to be hashable in swift 4?

2017-07-07 Thread Adrian Zubarev via swift-users
Welcome to the group of people who thinks that the character from Monopoly had a monocle, including myself. You've just experienced a transdimensional jump from your universe without even notecing, but where Swift 4 actually had hashable tuples. :) Jokes aside, I haven't read anything about it

Re: [swift-users] is this a defect in equatable for swift tuples?

2017-07-09 Thread Adrian Zubarev via swift-users
Easy: class SomeClass : Equatable { --  Adrian Zubarev Sent with Airmail Am 9. Juli 2017 um 17:11:14, David Baraff via swift-users (swift-users@swift.org) schrieb: Given 2-tuples of type (T1, T2), you should be able to invoke the == operator if you could on both types T1 and T2, right?  i.e.

Re: [swift-users] How to write better Swift

2017-07-10 Thread Adrian Zubarev via swift-users
It should be willSet because in the example the job is executed before the new value is set. class SomeClass { var status: Int { willSet { guard newValue != self.status { return } // do something here } } } --  Adrian Zubarev Sent with Airmail A

Re: [swift-users] ⁨Is it possible to store a set of heterogeneous items with protocol?

2017-07-11 Thread Adrian Zubarev via swift-users
If the solution you seek is not designed so that the module user can extend the set of types then you could wrap your types into enum cases and use the enum for your set. ;) When Swift will support anonymous enum cases, this will be an elegant solution to these type of things. -- Adrian Zub

Re: [swift-users] ⁨Is it possible to store a set of heterogeneous items with protocol?

2017-07-11 Thread Adrian Zubarev via swift-users
No it does not have to be a generic enum at all, as long you do not want extending the types from a diffrent module. Simply add a new enum case for each type you need, like `case string(String)`. You may also want to ask the wrapped type for it's hashValue so that it will hash correctly. -- A

Re: [swift-users] How does "Sequence.joined" work?

2017-08-08 Thread Adrian Zubarev via swift-users
Moving this thread to the correct mailing list. Am 8. August 2017 um 06:36:18, Félix Cloutier via swift-evolution (swift-evolut...@swift.org) schrieb: All this means is that `joined()` does not create an array that contains the new result. It's only as magic as the COW semantics on arrays. Le

Re: [swift-users] Type of expression is ambiguous for static tuples

2017-09-01 Thread Adrian Zubarev via swift-users
It’s because the compiler does not support this yet. It’s the same with `let cgColor: CGColor = .clear.cgColor // will not work`. Instead you need to write `UIColor.clear.cgColor` or in your case `Double.phythagoreanTruple.0` Am 1. September 2017 um 12:17:57, Rudolf Adamkovič via swift-users

Re: [swift-users] Type of expression is ambiguous for static tuples

2017-09-01 Thread Adrian Zubarev via swift-users
is a property on Double so it does feel like a bug. On 1 Sep 2017, at 13:31, Adrian Zubarev via swift-users wrote: It’s because the compiler does not support this yet. It’s the same with `let cgColor: CGColor = .clear.cgColor // will not work`. Instead you need to write `UIColor.clear.cgColor

[swift-users] Foundation bug or indended?

2017-09-04 Thread Adrian Zubarev via swift-users
Hi there, before filing a new issue I would like to ask if this is intended behaviour or a bug: The Foundation class Operation which has it’s roots in Objective-C has a few readonly properties like the following one: @available(iOS 2.0, *) open class Operation : NSObject { ... open var

Re: [swift-users] Problem with Access Control and Extensions

2017-09-20 Thread Adrian Zubarev via swift-users
I don’t get your problem here. If you don’t want to debate the correctness of your code, why are you asking for help or even showing error messages for a code snippet that cannot work? 1. Drop the access modifier from the extension itself, because this is only for convenience, which may or may

Re: [swift-users] A somewhat stupid question about protocol conformances

2017-11-25 Thread Adrian Zubarev via swift-users
This is correct. None of your types does conform to your protocol because you never conformance explicitly. The extenstion you wrote is just a conditional extension which says if the Self type conforms to AreaProtocol and the associated typed Element is a CGPoint then add the area method to it

Re: [swift-users] A somewhat stupid question about protocol conformances

2017-11-25 Thread Adrian Zubarev via swift-users
Sorry yeah you’re right, the example also requires conditional conformances. If you do not need dynamic dispatch in your use case then you can workaround the issue for now by hiding the protocol requirements and abusing the protocol extension: import UIKit protocol AreaProtocol { /* keep it e

[swift-users] Happy new year Swift community.

2017-12-31 Thread Adrian Zubarev via swift-users
Well some of you guys have to wait a little longer, but I can already wish everyone a happy new year from Germany. 🎉🎊🎆🎇 -- Adrian Zubarev Sent with Airmail ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/s