Commit Graph

16 Commits

Author SHA1 Message Date
Dmitri Hrybenko
270ec3b67c stdlib: protocol extensions: de-underscore reduce()
Swift SVN r28237
2015-05-07 00:30:25 +00:00
Dmitri Hrybenko
035d72d5a7 stdlib: protocol extensions: de-underscore contains()
Swift SVN r28236
2015-05-07 00:30:24 +00:00
Dmitri Hrybenko
822ad74194 stdlib: protocol extensions: de-underscore lexicographicalCompare()
Swift SVN r28235
2015-05-07 00:30:23 +00:00
Dmitri Hrybenko
78d1196f33 stdlib: protocol extensions: de-underscore elementsEqual
Swift SVN r28234
2015-05-07 00:30:22 +00:00
Dmitri Hrybenko
e43ad56a1c stdlib: protocol extensions: de-underscore startsWith()
Swift SVN r28233
2015-05-07 00:30:21 +00:00
Dmitri Hrybenko
62aa1f0e7c stdlib: protocol extensions: de-underscore minElement(), maxElement()
Swift SVN r28232
2015-05-07 00:30:20 +00:00
Dmitri Hrybenko
7e9063a4af stdlib: protocol extensions: de-underscore enumerate()
Swift SVN r28231
2015-05-07 00:30:12 +00:00
Dave Abrahams
4ce1891cae [stdlib] String is no longer a SequenceType
<rdar://20494686>

String itsef should only expose Unicode-correct algorithms, like proper
substring/prefix/suffix search, enumerating words/lines/paragraphs, case
folding etc. Promoting sequence-centric algorithms to methods on String
is not acceptable since it invites users to write wrong code. Thus,
String has to lose its SequenceType conformance.

Nevertheless, we recognize that sometimes it is useful to manipulate the
String contents on lower levels (UTF-8, UTF-16, Unicode scalars,
extended grapheme clusters), for example, when implementing high-level
Unicode operations, so we can't remove low-level operations
altogether. For this reason, String provides nested "views" for the
first three low-level representations, but grapheme clusters were in a
privileged position -- String itself is a collection of grapheme
clusters. We propose to add a characters view that will represent the
String as a collection of Character values.

Swift SVN r28065
2015-05-02 01:52:02 +00:00
Dmitri Hrybenko
16ab7b4a3b stdlib: rename equalElements() to elementsEqual() per API review
Swift SVN r27937
2015-04-29 22:34:59 +00:00
Dmitri Hrybenko
fd14e70e48 stdlib: rename find() to indexOf() per API review
Swift SVN r27849
2015-04-28 00:30:37 +00:00
David Farler
9e28dc777a Update standard library doc comments to Markdown
rdar://problem/20180478

Swift SVN r27726
2015-04-26 00:07:11 +00:00
Doug Gregor
793b3326af Implement the new rules for argument label defaults.
The rule changes are as follows:
  * All functions (introduced with the 'func' keyword) have argument
  labels for arguments beyond the first, by default. Methods are no
  longer special in this regard.
  * The presence of a default argument no longer implies an argument
  label.

The actual changes to the parser and printer are fairly simple; the
rest of the noise is updating the standard library, overlays, tests,
etc.

With the standard library, this change is intended to be API neutral:
I've added/removed #'s and _'s as appropriate to keep the user
interface the same. If we want to separately consider using argument
labels for more free functions now that the defaults in the language
have shifted, we can tackle that separately.

Fixes rdar://problem/17218256.

Swift SVN r27704
2015-04-24 19:03:30 +00:00
Dmitri Hrybenko
d267b86cb6 stdlib: move the bulk of SequenceType algorithms to protocol extensions
rdar://19895265

Swift SVN r27269
2015-04-14 01:53:19 +00:00
Chris Lattner
20f8f09ea8 Land: <rdar://problem/19382905> improve 'if let' to support refutable patterns and untie it from optionals
This changes 'if let' conditions to take general refutable patterns, instead of
taking a irrefutable pattern and implicitly matching against an optional.

Where before you might have written:
  if let x = foo() {

you now need to write:
  if let x? = foo() {
    
The upshot of this is that you can write anything in an 'if let' that you can
write in a 'case let' in a switch statement, which is pretty general.

To aid with migration, this special cases certain really common patterns like
the above (and any other irrefutable cases, like "if let (a,b) = foo()", and
tells you where to insert the ?.  It also special cases type annotations like
"if let x : AnyObject = " since they are no longer allowed.

For transitional purposes, I have intentionally downgraded the most common
diagnostic into a warning instead of an error.  This means that you'll get:

t.swift:26:10: warning: condition requires a refutable pattern match; did you mean to match an optional?
if let a = f() {
       ^
        ?

I think this is important to stage in, because this is a pretty significant
source breaking change and not everyone internally may want to deal with it
at the same time.  I filed 20166013 to remember to upgrade this to an error.

In addition to being a nice user feature, this is a nice cleanup of the guts
of the compiler, since it eliminates the "isConditional()" bit from
PatternBindingDecl, along with the special case logic in the compiler to handle
it (which variously added and removed Optional around these things).




Swift SVN r26150
2015-03-15 07:06:22 +00:00
Chris Lattner
5549775677 enhance silgen to treat OptionalSomePattern and EnumElementPattern as
"similar", avoiding false positive "not exhaustive" diagnostics on switches
like:

switch ... {
case let x?: break
case .None: break
}

Also, start using x? patterns in the stdlib more (review appreciated!), which 
is what shook this issue out.



Swift SVN r26004
2015-03-12 00:39:43 +00:00
Dmitri Hrybenko
350248dae5 Reorganize the directory structure under 'stdlib'
The standard library has grown significantly, and we need a new
directory structure that clearly reflects the role of the APIs, and
allows future growth.

See stdlib/{public,internal,private}/README.txt for more information.

Swift SVN r25876
2015-03-09 05:26:05 +00:00