Commit Graph

47 Commits

Author SHA1 Message Date
Patrick Pijnappel
a61839d696 [stdlib] Add ordering guarantee to min() and max() docs 2015-12-18 09:51:34 +11:00
Patrick Pijnappel
fe478b7633 [stdlib] Add sort stability comment to min()/max() 2015-12-17 14:17:50 +11:00
Patrick Pijnappel
75a6609c61 [stdlib] Unabbreviate local variable names 2015-12-17 14:07:58 +11:00
Patrick Pijnappel
370f4f0de4 [stdlib] Refactor min(_:_:_:_:) 2015-12-17 14:00:03 +11:00
Patrick Pijnappel
220f2d1c89 [stdlib] Refactor min(_:_:) 2015-12-17 13:59:48 +11:00
Arsen Gasparyan
9f728c6dbd [stdlib] Make comparison operator choices consistent 2015-12-16 22:50:36 +03:00
Arsen Gasparyan
ee97757756 Set default value 2015-12-15 23:30:08 +03:00
Patrick Pijnappel
95622c435b [stdlib] Replace .Some(x) and .None by x and nil, respectively 2015-12-13 12:10:43 +11:00
codestergit
6e85e69283 [stdlib] Using map and guard let for nil handling 2015-12-06 04:01:33 +05:30
Johan K. Jensen
fa76656c82 Remove instances of duplicated words 2015-12-03 20:00:29 +01:00
Dmitri Hrybenko
dd3194a18c stdlib: adopt @warn_unused_result
rdar://20957486

Swift SVN r31048
2015-08-06 14:53:18 +00:00
Dave Abrahams
f59279dc31 [stdlib] Fix a couple of availability message
Swift SVN r31025
2015-08-05 20:02:34 +00:00
David Farler
0d1b03086d Add slicing extensions to SequenceType and CollectionType.
rdar://problem/21663830

Add the following new requirements to SequenceType with default implementations:

- dropFirst(n)
- dropLast(n)
- prefix(n)
- suffix(n)
- split(n)

In addition, provide specialized default implementations of these for CollectionTypes with forward, bidirectional, and random-access Index types where possible.

Add the following new requirements to CollectionType with default implementations:

- prefixThrough(n)
- prefixUpTo(n)
- suffixFrom(n)
- split() // isSeparator closure

Add the following convenience APIs:

- dropFirst() -> calls dropFirst(1)
- dropLast() -> calls dropLast(1)

Add a tentative underscored API:

- split() // takes Equatable separator.

Some APIs have undefined behavior when creating slices where the endpoints go beyond the bounds of the underlying collection. This will be fixed later by trapping creation of slices with invalid indices (rdar://problem/21822657).

Swift SVN r30371
2015-07-18 06:51:22 +00:00
Dave Abrahams
913f09838a [stdlib] Add a default generate() for generators...
...that are also sequences, and rip out all redundant implementations of
generate() that match a default.

Swift SVN r30035
2015-07-09 19:49:24 +00:00
Dmitri Hrybenko
80b1380fe8 stdlib: fold Sliceable into CollectionType and de-underscore SubSequence
Swift SVN r29845
2015-07-01 18:31:25 +00:00
Dmitri Hrybenko
fdd73a57b4 stdlib: add tests for generic parameter names on EnumerateGenerator,
EnumerateSequence

Part of rdar://21429126

Swift SVN r29629
2015-06-24 20:41:58 +00:00
Dmitri Hrybenko
55bb9a806b stdlib: replace implementations of unavailable functions with fatalError()
Reduces the stdandard library dylib size by 10 Kb for each slice.

Swift SVN r28884
2015-05-21 20:22:13 +00:00
Dmitri Hrybenko
53f3ccf850 stdlib: change CollectionType.count() into a property
Swift SVN r28829
2015-05-20 09:14:43 +00:00
Dmitri Hrybenko
6aa84e164d stdlib: clean up some FIXMEs for protocol extensions
Swift SVN r28661
2015-05-16 04:26:21 +00:00
Dmitri Hrybenko
313701286b stdlib: Various punctuation and markup improvements to the comments.
Patch by Brian Lanier.

Swift SVN r28659
2015-05-16 03:04:51 +00:00
Ted Kremenek
62feb5c949 Change @availability to @available.
This came out of today's language review meeting.
The intent is to match #available with the attribute
that describes availability.

This is a divergence from Objective-C.

Swift SVN r28484
2015-05-12 20:06:13 +00:00
Dmitri Hrybenko
68ef59e37a stdlib: Convert comments to use '- requires:' instead of 'Requires:'.
Tidy misc. comments and markdown along the way.

Patch by Brian Lanier.

Swift SVN r28473
2015-05-12 17:47:11 +00:00
Dave Abrahams
5c55682d8b [stdlib] Capitalize keywords in doc comments
Again, the text is a lot more readable that way.

Swift SVN r28472
2015-05-12 16:59:13 +00:00
Dave Abrahams
106b39a497 [stdlib] Indent bullet continuations in doc comments
The text is a lot more readable that way.

Swift SVN r28471
2015-05-12 16:59:08 +00:00
Dmitri Hrybenko
1bc7b4c226 Move requirements out of abstracts.
Searched for "/// ..*Requires:" and did manual replacements.

Patch by Alex Martini.

Swift SVN r28465
2015-05-12 07:39:52 +00:00
Chris Lattner
c1df892d47 improve stdlib hygiene a bit.
Swift SVN r28392
2015-05-10 02:55:18 +00:00
Dmitri Hrybenko
7776ba5a71 stdlib: clean up capitalization in doc comments
Patch by Brian Lanier and Alex Martini.

Swift SVN r28335
2015-05-08 23:44:05 +00:00
Dmitri Hrybenko
f46f16ae82 stdlib: implement new print() API
rdar://20775683

Swift SVN r28309
2015-05-08 01:37:59 +00:00
Dmitri Hrybenko
c109ec9125 stdlib: protocol extensions: de-underscore count()
Swift SVN r28246
2015-05-07 00:30:38 +00:00
Dmitri Hrybenko
e253881b02 stdlib: protocol extensions: de-underscore indices
Swift SVN r28245
2015-05-07 00:30:35 +00:00
Dmitri Hrybenko
f76ca6243e stdlib: protocol extensions: de-underscore indexOf()
Swift SVN r28244
2015-05-07 00:30:33 +00:00
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