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 wan

Re: [swift-users] question about swift and c callbacks

2017-01-04 Thread Yang Yang via swift-users
Thanks. It compiled successfully now under linux. 2017-01-04 12:29 GMT-06:00 Joe Groff : > > > On Dec 30, 2016, at 11:17 AM, Yang Yang via swift-users < > swift-users@swift.org> wrote: > > > > I try to wrap a c library in swift package named Test. > > The code looks like this: > > > > Test1.h >

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 Saagar Jha via swift-users
Ahh, I get what you’re saying now. In this case I’d like to see a warning when a “conflicting” function is defined that there may be potential ambiguity. Saagar Jha > On Jan 4, 2017, at 8:19 PM, Wagner Truppel wrote: > > Indeed, and in this case as well the compiler issues no warning even th

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 Wagner Truppel via swift-users
Indeed, and in this case as well the compiler issues no warning even though the ambiguity is evident. I had to try it on a playground to be sure that it’s the parameter-less foo() rather than the default-argumented foo(x:) that gets invoked when we call foo() on an instance. Of course, both thi

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 Jacob Bandes-Storch via swift-users
The same ambiguity occurs even without inheritance: class C { func foo() {} func foo(x: Int = 0) {} } Somewhat related: https://bugs.swift.org/browse/SR-1408 On Wed, Jan 4, 2017 at 7:42 PM, Wagner Truppel via swift-users < swift-users@swift.org> wrote: > I’m afraid I wasn’t clear enoug

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 Wagner Truppel via swift-users
I’m afraid I wasn’t clear enough on my post. The default value I referred to is the “= 0”. Had it been absent, the call c.foo() would undeniably be fulfilled by the parent class. However, with the default argument value, it’s not obvious whether c.foo() should be the parent’s implementation or t

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 Saagar Jha via swift-users
I’m not quite sure what you mean by "restrictions of parent implementations”, however, the “default value” you’re mentioning is a fundamental part of OOP–when a subclass overrides a superclass, it gets the parent class’s methods for free. There’s no need to issue a warning for this, since it’s e

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

2017-01-04 Thread Wagner Truppel via swift-users
Hello, I wasn’t sure whether to post this message here, at swift-dev, or at swift-evolution. so I’ll try here first. Hopefully it will get to the right group of people or, if not, someone will point me to the right mailing list. I came across a situation that boils down to this example: class

Re: [swift-users] How much memory does withMemoryRebound bind

2017-01-04 Thread Andrew Trick via swift-users
> On Dec 29, 2016, at 2:03 PM, Guillaume Lessard via swift-users > wrote: > > Hi Etan, > > `withMemoryRebound` does not copy memory. > The proposal for UnsafeRawPointer contains information about the memory model > (as related to pointers): > https://github.com/apple/swift-evolution/blob/mast

Re: [swift-users] Zero cost abstraction 2D Iterator (equivalent to two nested for loops) impossible?

2017-01-04 Thread Jens Persson via swift-users
I noticed disabling safety checks made the custom Iterator as fast as the two nested for-loops. Karl, how does your test change when disabling safety checks? Anyone having an idea why disabling safety checks should make the two sum funcs equally fast in my example program? (It shouldn't be the pr

Re: [swift-users] question about swift and c callbacks

2017-01-04 Thread Joe Groff via swift-users
> On Dec 30, 2016, at 11:17 AM, Yang Yang via swift-users > wrote: > > I try to wrap a c library in swift package named Test. > The code looks like this: > > Test1.h > > struct MyParams { > int (*func)(); > }; > > typedef struct MyParams MyParams; > > Test2.h > #include "Test1.h" > >

Re: [swift-users] are large values (not passed through a protocol) ever put on the heap?

2017-01-04 Thread Joe Groff via swift-users
> On Jan 3, 2017, at 10:04 PM, Ray Fix via swift-users > wrote: > > > There was a great talk at WWDC 2016 about internals and Swift performance. > https://developer.apple.com/videos/play/wwdc2016/416/ > > > At one point, Arnold Schwai

Re: [swift-users] Zero cost abstraction 2D Iterator (equivalent to two nested for loops) impossible?

2017-01-04 Thread Jens Persson via swift-users
Thanks, I wonder if it is currently impossible to make it as fast as the nested for loops, ie that some optimizer improvement could fix it. Here's a stripped down version of my code: import QuartzCore // This is just for timing using CACurrentMediaTime() struct Point2DInt { var x: Int v

Re: [swift-users] Zero cost abstraction 2D Iterator (equivalent to two nested for loops) impossible?

2017-01-04 Thread Karl via swift-users
Hmmm that’s interesting. A brief test I ran: import CoreGraphics import Foundation struct PointIterator { let rect: CGRect var nextPoint: CGPoint let maxX: CGFloat let maxY: CGFloat init(rect: CGRect) { self.rect = rect.standardized self.nextPoint = self.rect.origin /

[swift-users] Zero cost abstraction 2D Iterator (equivalent to two nested for loops) impossible?

2017-01-04 Thread Jens Persson via swift-users
Hi, I'm working on some low-level pixel processing code (stuff that is not possible to do using standard API or on eg GPU), and I had lots of eg these: for y in someStartY ..< someStopY { for x in someStartX ..< someStopX { ... pixels[x, y] ... } } So I implemented some (value) t