Re: [swift-evolution] Protocol conformance error

2018-01-17 Thread C. Keith Ray via swift-evolution
class M: C { func test(x: A) {} } there's no "override" keyword, so I think you're overloading. C. Keith Ray https://leanpub.com/wepntk <- buy my book? http://agilesolutionspace.blogspot.com/ twitter: @ckeithray http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf > On Jan 17,

Re: [swift-evolution] String update

2018-01-16 Thread C. Keith Ray via swift-evolution
people may want digits as characters in order to see zeros. parsing phone numbers and social security numbers need zeros. C. Keith Ray https://leanpub.com/wepntk <- buy my book? http://agilesolutionspace.blogspot.com/ twitter: @ckeithray

Re: [swift-evolution] [Proposal] Random Unification

2018-01-13 Thread C. Keith Ray via swift-evolution
Could someone measure how bad the "random(32 bits) mod m" problem actually is? It's prominent when the number of bits is close to m, eg 4 bits and m == 3. Is it bad when bits == 32 and m is less than 2^16? Or bits == 64 and m is less than 2^32? C. Keith Ray https://leanpub.com/wepntk <- buy my

Re: [swift-evolution] [pitch] adding toggle to Bool

2018-01-13 Thread C. Keith Ray via swift-evolution
(I know isTrue is redundant. I only considered it for symmetry.) > On Jan 13, 2018, at 11:09 AM, C. Keith Ray wrote: > > If you would like something better than "== false" I suggest adding computed > properties 'isTrue' and 'isFalse' to Boolean. > > >> On Jan 13, 2018, at

Re: [swift-evolution] [pitch] adding toggle to Bool

2018-01-13 Thread C. Keith Ray via swift-evolution
If you would like something better than "== false" I suggest adding computed properties 'isTrue' and 'isFalse' to Boolean. > On Jan 13, 2018, at 11:06 AM, Karl Wagner via swift-evolution > wrote: > > > >> On 12. Jan 2018, at 20:54, Alejandro Martinez via

Re: [swift-evolution] String update

2018-01-11 Thread C. Keith Ray via swift-evolution
That looks great. One thing I would look for is iterating over multiple matches in a string. I'd want to see lazy and non-lazy sequences. let wordMatcher = Regex(":w*") // or whatever matches word-characters // separated by non-word character. for w in aString[allMatches:

Re: [swift-evolution] [Review] SE-0194: Derived Collection of Enum Cases

2018-01-10 Thread C. Keith Ray via swift-evolution
Simple is better. Int indexes, please. -- C. Keith Ray * https://leanpub.com/wepntk <- buy my book? * http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf * http://agilesolutionspace.blogspot.com/ > On Jan 10, 2018, at 10:44 AM, Karl Wagner via swift-evolution >

Re: [swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

2017-12-12 Thread C. Keith Ray via swift-evolution
in https://gist.github.com/lattner/b016e1cf86c43732c8d82f90e5ae5438 there is this statement: "For this reason, the compiler only permits conformance of this protocol on the original type definition, not extensions" and this example: extension JSON : DynamicMemberLookupProtocol {

Re: [swift-evolution] Optional Argument Chaining

2017-12-11 Thread C. Keith Ray via swift-evolution
You can create a binary operator that tests the left-hand operand for nil, and passes the unwrapped value to the right-hand operand (a function taking one value), this operator can be made left-associative to allow chaining. let m = String(contentsOfFile: "README.md") ??? Markdown where ??? is

Re: [swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

2017-12-09 Thread C. Keith Ray via swift-evolution
I agree. Instead of a magic protocol, think I'd rather see "@dynamic" used like "@objc" is today. Maybe only applicable to class declarations. Implicitly unwrapped sounds reasonable... need to think on that some more. -- C. Keith Ray * https://leanpub.com/wepntk <- buy my book? *

Re: [swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

2017-12-07 Thread C. Keith Ray via swift-evolution
ote: > > >> Le 7 déc. 2017 à 16:33, C. Keith Ray via swift-evolution >> <swift-evolution@swift.org> a écrit : >> >> Let's see what disasters were created by people abusing NSProxy, the ObjC >> moral equivalent of a dynamic member lookup type. >>

Re: [swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

2017-12-07 Thread C. Keith Ray via swift-evolution
Let's see what disasters were created by people abusing NSProxy, the ObjC moral equivalent of a dynamic member lookup type. I'm not aware of anything. -- C. Keith Ray * https://leanpub.com/wepntk <- buy my book? * http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf *

Re: [swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

2017-12-05 Thread C. Keith Ray via swift-evolution
static type checking is no guarantee of program correctness. you can take a correct, functioning program in Java, for example, strip out all the type declarations and change the syntax to Groovy, and still have a correct, functioning program. (if you avoid methods overloaded on parameter

Re: [swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

2017-12-04 Thread C. Keith Ray via swift-evolution
BTW, Java via JNI would be another good application of this proposal. I once used a JNI wrapper library in C++ and it was pretty hairy and tedious. I think we might want to declare a "Python object" as implementing swift protocols. If the methods that implement a protocol are NOT implemented in

Re: [swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

2017-12-04 Thread C. Keith Ray via swift-evolution
Not everyone uses the IDE as a crutch for writing code. As someone who has used many languages, editors, and operating systems, I don't rely on autocomplete and sometimes turn it off because it gets in my way. my experience with C# was sometimes frustrating because it could be hard to find the

Re: [swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

2017-12-04 Thread C. Keith Ray via swift-evolution
> Yes, IMO such code should be second class citizen in Swift. Just have the compiler emit "your code is bad and you should be ashamed of it." -- C. Keith Ray * https://leanpub.com/wepntk <- buy my book? * http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf *

Re: [swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

2017-12-03 Thread C. Keith Ray via swift-evolution
I *don't* want dynamic calls to stand out. I want seamless interoperability. let arrayOfDogs = [ Python.Module(dog).Dog("Brianna"), Python.Module(dog).Dog("Kevin") ] // Swift array of Python objects let b = arrayOfDogs.sorted() // use Swift 'sort' function on Python objects (invoking Python '<'

Re: [swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

2017-12-01 Thread C. Keith Ray via swift-evolution
Should we compare dynamic member lookup to Microsoft's DLR ? https://docs.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/dynamic-language-runtime-overview Quote: The dynamic language runtime (DLR) is a runtime environment that adds a set of services for dynamic languages to the

Re: [swift-evolution] [Review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-13 Thread C. Keith Ray via swift-evolution
> On Nov 12, 2017, at 10:54 AM, Paul Cantrell via swift-evolution > wrote: > > >> On Nov 11, 2017, at 8:35 AM, Gwendal Roué via swift-evolution >> wrote: >> >> I'd suggest `compactMap` as an alternative name, should `filterMap` find

Re: [swift-evolution] [Pitch] Improving capturing semantics of local functions

2017-11-12 Thread C. Keith Ray via swift-evolution
> Another option that reads nicely IMHO is > > func fn(param: T) throws -> T where T : Equatable [foo, bar] { … } > I changed my mind. Putting the capture list just before { } is where I'd rather see it. > I think #4 is ambiguous with array literals unfortunately. > > Perhaps this proposal

Re: [swift-evolution] [Pitch] Improving capturing semantics of local functions

2017-11-12 Thread C. Keith Ray via swift-evolution
I'd vote for # 1 Starting with "func" helps signal that the context is a function. (Though I know some things can precede "func".) Having the function name second is important to me: you don't have to scan further for its name. Template arguments seem more important than capture lists, so

Re: [swift-evolution] [Pitch] Introduce user-defined dynamically "callable" types

2017-11-11 Thread C. Keith Ray via swift-evolution
how does c code (and Python code, etc, other than ObjC) call Swift functions, methods, etc? C. Keith Ray https://leanpub.com/wepntk <- buy my book? http://agilesolutionspace.blogspot.com/ twitter: @ckeithray http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf > On Nov 11, 2017, at

Re: [swift-evolution] Abstract methods

2017-11-03 Thread C. Keith Ray via swift-evolution
utionspace.blogspot.com/ > On Nov 3, 2017, at 8:33 AM, C. Keith Ray via swift-evolution > <swift-evolution@swift.org> wrote: > > If protocols can (1) store data (2) implement methods (3) force "subclasses" > to implement methods, then I'm ok that it isn't spelled &q

Re: [swift-evolution] Abstract methods

2017-11-03 Thread C. Keith Ray via swift-evolution
If protocols can (1) store data (2) implement methods (3) force "subclasses" to implement methods, then I'm ok that it isn't spelled "abstract". And yes, I know 2 and 3 done. -- C. Keith Ray * https://leanpub.com/wepntk <- buy my book? *

Re: [swift-evolution] Abstract methods

2017-11-02 Thread C. Keith Ray via swift-evolution
, particularly around metatypes and > constructors, because now we have this new concept of a class that cannot be > directly instantiated. I’m not sure the cost is worth the benefit. > > Slava > >> On Nov 2, 2017, at 12:45 PM, C. Keith Ray via swift-evolution >> &l

[swift-evolution] Abstract methods

2017-11-02 Thread C. Keith Ray via swift-evolution
How many "subclass must override" assertions or comments in base class methods do we need to see, to want to add "abstract" to the Swift language? 5? 50? 500? It's a not uncommon idiom in Objective-C. I'm about to port a substantial amount of C++ code to swift, and compiler help to enforce

Re: [swift-evolution] classprivate protection level?

2017-10-30 Thread C. Keith Ray via swift-evolution
Access levels are not a security mechanism. You have to trust your (fellow) programmers. Lots of good software has been created in Smalltalk and other languages without "private" access levels. -- C. Keith Ray * https://leanpub.com/wepntk <- buy my book? *

Re: [swift-evolution] [Discussion] Swift for Data Science / ML / Big Data analytics

2017-10-29 Thread C. Keith Ray via swift-evolution
There's surprisingly little information about Cython interoperability with Cocoa/Mac applications. It's might be linkable if the app can embed Python. -- C. Keith Ray * https://leanpub.com/wepntk <- buy my book? * http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf *

Re: [swift-evolution] [Discussion] Swift for Data Science / ML / Big Data analytics

2017-10-29 Thread C. Keith Ray via swift-evolution
It would be really nice if Cython code could be linked into iOS and Mac apps written in Swift or Objective-C. http://cython.org -- C. Keith Ray Senior Software Engineer / Trainer / Agile Coach * http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf > On Oct 29, 2017, at 1:34 PM,

Re: [swift-evolution] Pitch: Member lookup on String should not find members of NSString

2017-10-28 Thread C. Keith Ray via swift-evolution
is there a roadmap for strings + unicode in swift 5? will unicode normalization and other functionality be available in the standard library? https://docs.oracle.com/javase/8/docs/api/java/text/Normalizer.html https://www.unicode.org/reports/tr31/ http://www.unicode.org/reports/tr44/

Re: [swift-evolution] Making capturing semantics of local

2017-10-28 Thread C. Keith Ray via swift-evolution
> On Oct 28, 2017, at 1:47 AM, Tino Heth via swift-evolution > wrote: > > How about > func localFunc[weak self](input: Double) { > } > ? > Seems to be the obvious choice for me... +1 -- C. Keith Ray * https://leanpub.com/wepntk <- buy my book? *

Re: [swift-evolution] Making capturing semantics of local functions explicit

2017-10-25 Thread C. Keith Ray via swift-evolution
class A { func foo() -> ()->String { func local() -> String { [weak self] in return "foo \(self.i)" } return local } ... compares well with this... class A { func foo() -> ()->String { let local : () -> String = { [weak self] in

Re: [swift-evolution] [Draft] Rename Sequence.elementsEqual

2017-10-15 Thread C. Keith Ray via swift-evolution
Why not use an equals Implementation that doesn't rely on order? Something like this (which doesn't compile in my iPad playground). If two sets have the same number of elements, and every element in one can be found in the other, they are equal, otherwise they are not equal. protocol Set {

Re: [swift-evolution] /*Let it be*/ func() -> @discardable Bool {} /*Rather Than*/ @discardableResult func() -> Bool {}

2017-10-15 Thread C. Keith Ray via swift-evolution
+1 to "discardable" or "@discardable" next to the result type. ] A simple “discardable” would be great. If the result is Bool and ] “discardable” is placed right in front of it, it’s not only more readable ] but also eliminates the redundant word “Result”. Also no at sign is great. -- C. Keith

Re: [swift-evolution] Fix "private extension" (was "Public Access Modifier Respected in Type Definition")

2017-10-09 Thread C. Keith Ray via swift-evolution
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/AccessControl.html Says... "Alternatively, you can mark an extension with an explicit access-level modifier (for example, private extension) to set a new default access level for all members