Re: [swift-evolution] [swift-evolution-announce] [Review] SE-0117: Default classes to be non-subclassable publicly
+1 with modifications. In my team we write “final class” a lot. We also do have a lot of internal frameworks and an ability to guide external frameworks uses is important for us. We have a lot of candidates in our frameworks that should be inheritable internally, but we do not recommend to extend them outside of framework. My biggest worry with this proposal is already highlighted in a section "Modifier spelling alternatives”. Proposal introduces a set of new keywords to express relatively similar concept as current `final` keyword. We currently have already an ability to limit inheritance by use `final`, but we can not define a scope. However we also have keywords to define an accessibility scope: * public — accessible everywhere * internal — accessible within a module * private — accessible within a file For example, by leveraging existing keywords we can write code like following: final(internal) class Foo { final(private) func bar() { } } So the class `Foo` is inheritable within a module, but method bar is overridable only within same file. There is also optional `final(public)` that literally means no limitations on inheritance that can be used to indicate that class or method is `final(public)` on purpose by design. We use the similar approach in our code base with `internal`, while it is default keyword for classes and functions we still write it to show that it is internal by design and no public / private keyword missing. Also with suggestion above we can default `final` to `final(private)`to keep backwards compatibility. Best, Nikita Leonov > On Jul 5, 2016, at 4:11 PM, Chris Lattnerwrote: > > Hello Swift community, > > The review of "SE-0117: Default classes to be non-subclassable publicly" > begins now and runs through July 11. The proposal is available here: > > > https://github.com/apple/swift-evolution/blob/master/proposals/0117-non-public-subclassable-by-default.md > > Reviews are an important part of the Swift evolution process. All reviews > should be sent to the swift-evolution mailing list at > > https://lists.swift.org/mailman/listinfo/swift-evolution > > or, if you would like to keep your feedback private, directly to the review > manager. > > What goes into a review? > > The goal of the review process is to improve the proposal under review > through constructive criticism and contribute to the direction of Swift. When > writing your review, here are some questions you might want to answer in your > review: > > * What is your evaluation of the proposal? > * Is the problem being addressed significant enough to warrant a change > to Swift? > * Does this proposal fit well with the feel and direction of Swift? > * If you have used other languages or libraries with a similar feature, > how do you feel that this proposal compares to those? > * How much effort did you put into your review? A glance, a quick > reading, or an in-depth study? > > More information about the Swift evolution process is available at > > https://github.com/apple/swift-evolution/blob/master/process.md > > Thank you, > > -Chris Lattner > Review Manager > > ___ > swift-evolution-announce mailing list > swift-evolution-annou...@swift.org > https://lists.swift.org/mailman/listinfo/swift-evolution-announce ___ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution
Re: [swift-evolution] [Discussion] Static curried versions for variables and constants.
Great! I was trying to find it in a history, but was not able to do so. Thanks for suggestion regarding lens keyword. > On Jul 2, 2016, at 3:10 PM, Brent Royal-Gordon <br...@architechies.com> wrote: > >> On Jul 2, 2016, at 12:14 PM, Nikita Leonov via swift-evolution >> <swift-evolution@swift.org> wrote: >> >> I was trying to find what cause to not define static curried functions for >> variables and constants and was not able to find a good reason. > > In brief: This has been deferred until after Swift 3. We want to be able to > provide read-write access to read-write properties, but Swift can't do that > yet. (And at this point in Swift's release cycle, we're not really accepting > new features unless they have very large source compatibility impacts, which > this change wouldn't.) > > Here's one previous discussion from December: > <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003008.html> > If you want to look at more discussions on this topic, "lens" is a good > keyword, although it'll also pick up some unrelated stuff. > <https://www.google.com/?client=safari#q=lens+site:lists.swift.org> > > Hope this helps, > -- > Brent Royal-Gordon > Architechies > ___ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution
[swift-evolution] [Discussion] Static curried versions for variables and constants.
Currently Swift provides a static curried function for every instance function defined. It pretty often allows to avoid closures and be explicit about functions used. For example: //flip — flipping an order of arguments for curried functions. var foo = [[0, 1], [1, 2], [2, 3], [3, 4]].map(flip(Array.prefix)(1)) //[[0], [1], [2], [3]] However this behavior is not unified, there is no such behavior available for variables or constants. For example code like following is impossible as Array.first is a variable but not a function: var foo = [[0, 1], [1, 2], [2, 3], [3, 4]].map(Array.first) //Does not compile, but should be [0, 1, 2, 3] I was trying to find what cause to not define static curried functions for variables and constants and was not able to find a good reason. It is especially interesting as currently if you define both variable and instance function with the same name, Swift complains about redeclaration of function, so it it treat variable already as a function, but does not provide an alternative way to call it. Moreover following definitions of variable and static functions a conflicting, as variable definitely has its hidden curried implementation somewhere but invisible for others: class Foo { var bar: Int = 0 static func bar(self: Foo) -> Int {} //Definition conflicts with previous value } One of assumptions why curried functions for variables are hidden — it will cause ambiguity in code, but I was not able to find examples of ambiguity. Could someone explain why this behavior is not consistent across functions, variables and constants? Should we change it to be consistent and make visible curried static functions for variables and functions? Especially since it is in a nature of current implementation. Best, Nikita Leonov___ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution