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

2017-09-01 Thread Slava Pestov via swift-users
Yeah, my understanding is that .foo syntax only works if ‘foo’ is an immediate 
static member of the contextual type where the expression appears. So nested 
member access like .foo.b ar does not make sense.

Slava

> On Sep 1, 2017, at 6:04 AM, Adrian Zubarev via swift-users 
>  wrote:
> 
> Yet this is correct behavior because the compiler cannot traverse the 
> expression tree without knowing the root type of that expression tree. The 
> type information flow in such case should be from root to the leaves where 
> the root is NOT the root of the expression, but the type from the function 
> parameter, which then should be passed to the expression tree. However the 
> expression tree is not complete, because there MIGHT be another 
> `phythagoreanTruple` somewhere else. Even if there is no other 
> `phythagoreanTruple`, here the general rules are applied which results into 
> the mentioned error message.
> 
> Please correct me if I’m wrong here.
> 
> 
> Am 1. September 2017 um 14:53:35, David Hart (da...@hartbit.com 
> ) schrieb:
> 
>> Its slightly different though. In the case of:
>> 
>> let cgColor: CGColor = .clear.cgColor
>> 
>> clear is a static property on UIColor, not CGColor. In his example, 
>> pythagoreanTriple 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` or in your case 
>>> `Double.phythagoreanTruple.0`
>>> 
>>> 
>>> Am 1. September 2017 um 12:17:57, Rudolf Adamkovič via swift-users 
>>> (swift-users@swift.org ) schrieb:
>>> 
 Given the following extension ...
 
 extension Double {
 typealias Triple = (Double, Double, Double)
 static let pythagoreanTriple: Triple = (3, 4, 5)
 }
 ... why does Swift compiler emits the following errors?
 
 // Type of expression is ambiguous without more context
 let a: Double = .pythagoreanTriple.0
 
 // Type of expression is ambiguous without more context
 func f(_ x: Double) {}
 f(.pythagoreanTriple.0)
 The errors disappear with explicit Double.pythagoreanTriple.0.
 
 Why doesn't the compiler infer Double in this case?
 
 FYI: Posted also to Stack Overflow here:
 
 https://stackoverflow.com/questions/45998034/type-of-expression-is-ambiguous-for-static-tuples
  
 
 R+
 
 ___
 swift-users mailing list
 swift-users@swift.org 
 https://lists.swift.org/mailman/listinfo/swift-users
>>> ___
>>> swift-users mailing list
>>> swift-users@swift.org 
>>> https://lists.swift.org/mailman/listinfo/swift-users 
>>> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Writing a pod catcher for iOS

2017-09-01 Thread Nicholas Acosta via swift-users
Good afternoon, I was wondering if anyone can help me with creating a 
podcast/RSS reader in swift. I have been taking basic iOS courses and learning 
how to use Xcode. I am fully comfortable with using Xcode and the templates 
that are available in iOS. I am also familiar with the frameworks for audio and 
video in iOS. Now, I want to take it to the next level and create my own pod 
cast/RSS reader for the iPhone. I have been trying to do some research for a a 
while and nothing has turned up. Can someone help? I really enjoy using swift 
and I am just trying to learn as I go.

Thank you.

Sent from my iPhone
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


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

2017-09-01 Thread Adrian Zubarev via swift-users
Yet this is correct behavior because the compiler cannot traverse the 
expression tree without knowing the root type of that expression tree. The type 
information flow in such case should be from root to the leaves where the root 
is NOT the root of the expression, but the type from the function parameter, 
which then should be passed to the expression tree. However the expression tree 
is not complete, because there MIGHT be another `phythagoreanTruple` somewhere 
else. Even if there is no other `phythagoreanTruple`, here the general rules 
are applied which results into the mentioned error message.

Please correct me if I’m wrong here.


Am 1. September 2017 um 14:53:35, David Hart (da...@hartbit.com) schrieb:

Its slightly different though. In the case of:

let cgColor: CGColor = .clear.cgColor

clear is a static property on UIColor, not CGColor. In his example, 
pythagoreanTriple 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` or in your case 
`Double.phythagoreanTruple.0`


Am 1. September 2017 um 12:17:57, Rudolf Adamkovič via swift-users 
(swift-users@swift.org) schrieb:

Given the following extension ...

extension Double {
typealias Triple = (Double, Double, Double)
static let pythagoreanTriple: Triple = (3, 4, 5)
}
... why does Swift compiler emits the following errors?

// Type of expression is ambiguous without more context
let a: Double = .pythagoreanTriple.0

// Type of expression is ambiguous without more context
func f(_ x: Double) {}
f(.pythagoreanTriple.0)
The errors disappear with explicit Double.pythagoreanTriple.0.

Why doesn't the compiler infer Double in this case?

FYI: Posted also to Stack Overflow here:

https://stackoverflow.com/questions/45998034/type-of-expression-is-ambiguous-for-static-tuples

R+

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


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

2017-09-01 Thread David Hart via swift-users
Its slightly different though. In the case of:

let cgColor: CGColor = .clear.cgColor

clear is a static property on UIColor, not CGColor. In his example, 
pythagoreanTriple 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` or in your case 
> `Double.phythagoreanTruple.0`
> 
> 
> Am 1. September 2017 um 12:17:57, Rudolf Adamkovič via swift-users 
> (swift-users@swift.org ) schrieb:
> 
>> Given the following extension ...
>> 
>> extension Double {
>> typealias Triple = (Double, Double, Double)
>> static let pythagoreanTriple: Triple = (3, 4, 5)
>> }
>> ... why does Swift compiler emits the following errors?
>> 
>> // Type of expression is ambiguous without more context
>> let a: Double = .pythagoreanTriple.0
>> 
>> // Type of expression is ambiguous without more context
>> func f(_ x: Double) {}
>> f(.pythagoreanTriple.0)
>> The errors disappear with explicit Double.pythagoreanTriple.0.
>> 
>> Why doesn't the compiler infer Double in this case?
>> 
>> FYI: Posted also to Stack Overflow here:
>> 
>> https://stackoverflow.com/questions/45998034/type-of-expression-is-ambiguous-for-static-tuples
>>  
>> 
>> R+
>> 
>> ___
>> swift-users mailing list
>> swift-users@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
> ___
> swift-users mailing list
> swift-users@swift.org 
> https://lists.swift.org/mailman/listinfo/swift-users 
> 
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


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 
(swift-users@swift.org) schrieb:

Given the following extension ...

extension Double {
typealias Triple = (Double, Double, Double)
static let pythagoreanTriple: Triple = (3, 4, 5)
}
... why does Swift compiler emits the following errors?

// Type of expression is ambiguous without more context
let a: Double = .pythagoreanTriple.0

// Type of expression is ambiguous without more context
func f(_ x: Double) {}
f(.pythagoreanTriple.0)
The errors disappear with explicit Double.pythagoreanTriple.0.

Why doesn't the compiler infer Double in this case?

FYI: Posted also to Stack Overflow here:

https://stackoverflow.com/questions/45998034/type-of-expression-is-ambiguous-for-static-tuples

R+

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


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

2017-09-01 Thread Rudolf Adamkovič via swift-users
Given the following extension ...

extension Double {
typealias Triple = (Double, Double, Double)
static let pythagoreanTriple: Triple = (3, 4, 5)
}
... why does Swift compiler emits the following errors?

// Type of expression is ambiguous without more context
let a: Double = .pythagoreanTriple.0

// Type of expression is ambiguous without more context
func f(_ x: Double) {}
f(.pythagoreanTriple.0)
The errors disappear with explicit Double.pythagoreanTriple.0.

Why doesn't the compiler infer Double in this case?

FYI: Posted also to Stack Overflow here:

https://stackoverflow.com/questions/45998034/type-of-expression-is-ambiguous-for-static-tuples

R+___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Still can't derive from a generic class

2017-09-01 Thread Joanna Carter via swift-users
Hi Joe

Thanks for your input on this.

> This is likely due to the runtime not handling cycles properly in type 
> metadata initialization—a subclass T needs its base class metadata for 
> BaseObject, which in turn needs the metadata for T to instantiate the 
> generic type. This is something we plan to fix next year since it requires 
> runtime ABI changes.

Hmmm. I'm finding this really frustrating, waiting for features that I have 
been using for years, in another popular language (C#), to see the light of day.

Maybe application programmers are happy with Swift so far but, when it comes to 
my speciality of designing frameworks, I am constantly finding myself blocked 
by lack of metadata APIs :-(

I am talking about a couple of frameworks that underpin one of the largest 
business management systems in Europe, for which the client is asking a 
MacOS/iOS version.

> Would a protocol-based approach suffice? `Self` in a protocol extension would 
> give you access to the concrete type in a similar way:
> 
> protocol Base: AnyObject {
>  var properties:  [PartialKeyPath : AnyProperty] { get }
> }
> 
> extension Base {
>  func value(for keyPath: KeyPath) -> T?
>  {
>guard let property = properties[keyPath] else
>{
>  return nil
>}
> 
>return property.getValue()
>  }
> 
>  /*etc.*/
> }
> 
> class Test: Base {
>  let properties = [\Test.name: Property()]
> 
>  var name: String {
>get { return value(for: \.name) }
>set { set(value: newValue, for: \.name) }
>  }
> }

At first glance, I thought, Yes! But then I realised that this then requires a 
final class to cater for the use of Self in the protocol; something that would 
be a blocker for the class hierarchies that most users of the framework would 
want to create on top of the Base functionality.

I suppose I could look at using protocol-oriented composition but trying to 
avoid associated types in protocols in frameworks that use generics extensively 
is akin to hitting yourself repeatedly on the head with a hammer ;-)

And I really don't want to have to keep on repeating type-erasure boilerplate 
code to achieve that.

I think the realisation that I may well lose the chance of a pretty massive 
contract and that my client will lose an important business opportunity is 
finally dawning :-(

Joanna

--
Joanna Carter
Carter Consulting

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users