Some syntax errors in Swift's standard library, anyone knows why?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Some syntax errors in Swift's standard library, anyone knows why?

l̲̅e̲̅x̲̅ c̲̅h̲̅o̲̅u̲̅
I found several undocumented syntax in swift's standard library, or maybe we should call it syntax error, because these syntaxes even not supported by Xcode and Swift compiler:

func join<S : SequenceType where [T] == [T]>(elements: S) -> [T]

This is defined by type Swift.Array, according to Language References - Where Clauses, it must be an identifier after where for same-type-requirement, so it's a syntax-level error, and it's even not right in semantic level, I don't understand why there's a [T] = [T] requirement, anyone knows?

Another undocumented syntax example:

    mutating func removeAll(keepCapacity: Bool = default)


This is easy to understand although it's still not a valid swift syntax.

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/0ca329a0-cace-4d91-b596-1c90f56c7488%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Some syntax errors in Swift's standard library, anyone knows why?

Jens Alfke

On Apr 27, 2015, at 7:33 AM, l̲̅e̲̅x̲̅ c̲̅h̲̅o̲̅u̲̅ <[hidden email]> wrote:

I found several undocumented syntax in swift's standard library

I assume you’re finding these by Command-clicking in Xcode? That’s not the actual source code (which isn’t public.) It’s something Xcode generates on the fly by decompiling metadata in the compiled code. It’s entirely possible this decompiler has glitches that cause it to emit incorrect or nonsensical source code in some cases, and I’m guessing that’s what you’ve found. You could file a bug report with Apple.

—Jens

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/157D5513-2377-430A-9579-B7A9F6FB49E0%40mooseyard.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Some syntax errors in Swift's standard library, anyone knows why?

Chris Lattner
On Apr 27, 2015, at 9:53 AM, Jens Alfke <[hidden email]> wrote:
On Apr 27, 2015, at 7:33 AM, l̲̅e̲̅x̲̅ c̲̅h̲̅o̲̅u̲̅ <[hidden email]> wrote:

I found several undocumented syntax in swift's standard library

I assume you’re finding these by Command-clicking in Xcode? That’s not the actual source code (which isn’t public.) It’s something Xcode generates on the fly by decompiling metadata in the compiled code. It’s entirely possible this decompiler has glitches that cause it to emit incorrect or nonsensical source code in some cases, and I’m guessing that’s what you’ve found. You could file a bug report with Apple.

Yep, that’s exactly the case.  It is a known bug, thanks!

-Chris

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/0AD1E3EE-BF37-43ED-9A1C-3E391C4E6F05%40apple.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Some syntax errors in Swift's standard library, anyone knows why?

l̲̅e̲̅x̲̅ c̲̅h̲̅o̲̅u̲̅
In reply to this post by l̲̅e̲̅x̲̅ c̲̅h̲̅o̲̅u̲̅
@Jens Alfke @Chris Lattner
Thanks all!

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/e4bb3268-28f9-45d4-8b1d-b08ecbd9fd05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.