Skip to content

Commit b738eae

Browse files
committed
Merge branch 'travissarles-master' of github.com:scala/scala.github.com into travissarles-master
2 parents 4a9e1bc + 3937ef2 commit b738eae

5 files changed

+208
-60
lines changed

Gemfile.lock

+114-56
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,79 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (4.2.7)
4+
activesupport (4.2.8)
55
i18n (~> 0.7)
6-
json (~> 1.7, >= 1.7.7)
76
minitest (~> 5.1)
87
thread_safe (~> 0.3, >= 0.3.4)
98
tzinfo (~> 1.1)
10-
addressable (2.4.0)
9+
addressable (2.5.1)
10+
public_suffix (~> 2.0, >= 2.0.2)
1111
coffee-script (2.4.1)
1212
coffee-script-source
1313
execjs
14-
coffee-script-source (1.10.0)
14+
coffee-script-source (1.12.2)
1515
colorator (1.1.0)
16-
ethon (0.9.1)
16+
ethon (0.10.1)
1717
ffi (>= 1.3.0)
1818
execjs (2.7.0)
19-
faraday (0.9.2)
19+
faraday (0.12.1)
2020
multipart-post (>= 1.2, < 3)
21-
ffi (1.9.14)
21+
ffi (1.9.18)
2222
forwardable-extended (2.6.0)
23-
gemoji (2.1.0)
24-
github-pages (104)
25-
activesupport (= 4.2.7)
26-
github-pages-health-check (= 1.2.0)
27-
jekyll (= 3.3.0)
23+
gemoji (3.0.0)
24+
github-pages (143)
25+
activesupport (= 4.2.8)
26+
github-pages-health-check (= 1.3.4)
27+
jekyll (= 3.4.5)
2828
jekyll-avatar (= 0.4.2)
2929
jekyll-coffeescript (= 1.0.1)
30-
jekyll-feed (= 0.8.0)
30+
jekyll-default-layout (= 0.1.4)
31+
jekyll-feed (= 0.9.2)
3132
jekyll-gist (= 1.4.0)
32-
jekyll-github-metadata (= 2.2.0)
33+
jekyll-github-metadata (= 2.4.0)
3334
jekyll-mentions (= 1.2.0)
35+
jekyll-optional-front-matter (= 0.1.2)
3436
jekyll-paginate (= 1.1.0)
35-
jekyll-redirect-from (= 0.11.0)
36-
jekyll-sass-converter (= 1.3.0)
37-
jekyll-seo-tag (= 2.1.0)
38-
jekyll-sitemap (= 0.12.0)
37+
jekyll-readme-index (= 0.1.0)
38+
jekyll-redirect-from (= 0.12.1)
39+
jekyll-relative-links (= 0.4.1)
40+
jekyll-sass-converter (= 1.5.0)
41+
jekyll-seo-tag (= 2.2.3)
42+
jekyll-sitemap (= 1.0.0)
3943
jekyll-swiss (= 0.4.0)
40-
jemoji (= 0.7.0)
41-
kramdown (= 1.11.1)
44+
jekyll-theme-architect (= 0.0.4)
45+
jekyll-theme-cayman (= 0.0.4)
46+
jekyll-theme-dinky (= 0.0.4)
47+
jekyll-theme-hacker (= 0.0.4)
48+
jekyll-theme-leap-day (= 0.0.4)
49+
jekyll-theme-merlot (= 0.0.4)
50+
jekyll-theme-midnight (= 0.0.4)
51+
jekyll-theme-minimal (= 0.0.4)
52+
jekyll-theme-modernist (= 0.0.4)
53+
jekyll-theme-primer (= 0.3.0)
54+
jekyll-theme-slate (= 0.0.4)
55+
jekyll-theme-tactile (= 0.0.4)
56+
jekyll-theme-time-machine (= 0.0.4)
57+
jekyll-titles-from-headings (= 0.2.0)
58+
jemoji (= 0.8.0)
59+
kramdown (= 1.13.2)
4260
liquid (= 3.0.6)
4361
listen (= 3.0.6)
4462
mercenary (~> 0.3)
45-
minima (= 2.0.0)
63+
minima (= 2.1.1)
4664
rouge (= 1.11.1)
4765
terminal-table (~> 1.4)
48-
github-pages-health-check (1.2.0)
66+
github-pages-health-check (1.3.4)
4967
addressable (~> 2.3)
5068
net-dns (~> 0.8)
5169
octokit (~> 4.0)
52-
public_suffix (~> 1.4)
70+
public_suffix (~> 2.0)
5371
typhoeus (~> 0.7)
54-
html-pipeline (2.4.2)
72+
html-pipeline (2.6.0)
5573
activesupport (>= 2)
5674
nokogiri (>= 1.4)
57-
i18n (0.7.0)
58-
jekyll (3.3.0)
75+
i18n (0.8.6)
76+
jekyll (3.4.5)
5977
addressable (~> 2.4)
6078
colorator (~> 1.0)
6179
jekyll-sass-converter (~> 1.0)
@@ -70,70 +88,110 @@ GEM
7088
jekyll (~> 3.0)
7189
jekyll-coffeescript (1.0.1)
7290
coffee-script (~> 2.2)
73-
jekyll-feed (0.8.0)
91+
jekyll-default-layout (0.1.4)
92+
jekyll (~> 3.0)
93+
jekyll-feed (0.9.2)
7494
jekyll (~> 3.3)
7595
jekyll-gist (1.4.0)
7696
octokit (~> 4.2)
77-
jekyll-github-metadata (2.2.0)
97+
jekyll-github-metadata (2.4.0)
7898
jekyll (~> 3.1)
7999
octokit (~> 4.0, != 4.4.0)
80100
jekyll-mentions (1.2.0)
81101
activesupport (~> 4.0)
82102
html-pipeline (~> 2.3)
83103
jekyll (~> 3.0)
104+
jekyll-optional-front-matter (0.1.2)
105+
jekyll (~> 3.0)
84106
jekyll-paginate (1.1.0)
85-
jekyll-redirect-from (0.11.0)
86-
jekyll (>= 2.0)
87-
jekyll-sass-converter (1.3.0)
88-
sass (~> 3.2)
89-
jekyll-seo-tag (2.1.0)
107+
jekyll-readme-index (0.1.0)
108+
jekyll (~> 3.0)
109+
jekyll-redirect-from (0.12.1)
110+
jekyll (~> 3.3)
111+
jekyll-relative-links (0.4.1)
112+
jekyll (~> 3.3)
113+
jekyll-sass-converter (1.5.0)
114+
sass (~> 3.4)
115+
jekyll-seo-tag (2.2.3)
90116
jekyll (~> 3.3)
91-
jekyll-sitemap (0.12.0)
117+
jekyll-sitemap (1.0.0)
92118
jekyll (~> 3.3)
93119
jekyll-swiss (0.4.0)
120+
jekyll-theme-architect (0.0.4)
121+
jekyll (~> 3.3)
122+
jekyll-theme-cayman (0.0.4)
123+
jekyll (~> 3.3)
124+
jekyll-theme-dinky (0.0.4)
125+
jekyll (~> 3.3)
126+
jekyll-theme-hacker (0.0.4)
127+
jekyll (~> 3.3)
128+
jekyll-theme-leap-day (0.0.4)
129+
jekyll (~> 3.3)
130+
jekyll-theme-merlot (0.0.4)
131+
jekyll (~> 3.3)
132+
jekyll-theme-midnight (0.0.4)
133+
jekyll (~> 3.3)
134+
jekyll-theme-minimal (0.0.4)
135+
jekyll (~> 3.3)
136+
jekyll-theme-modernist (0.0.4)
137+
jekyll (~> 3.3)
138+
jekyll-theme-primer (0.3.0)
139+
jekyll (~> 3.3)
140+
jekyll-theme-slate (0.0.4)
141+
jekyll (~> 3.3)
142+
jekyll-theme-tactile (0.0.4)
143+
jekyll (~> 3.3)
144+
jekyll-theme-time-machine (0.0.4)
145+
jekyll (~> 3.3)
146+
jekyll-titles-from-headings (0.2.0)
147+
jekyll (~> 3.3)
94148
jekyll-watch (1.5.0)
95149
listen (~> 3.0, < 3.1)
96-
jemoji (0.7.0)
150+
jemoji (0.8.0)
97151
activesupport (~> 4.0)
98-
gemoji (~> 2.0)
152+
gemoji (~> 3.0)
99153
html-pipeline (~> 2.2)
100154
jekyll (>= 3.0)
101-
json (1.8.6)
102-
kramdown (1.11.1)
155+
kramdown (1.13.2)
103156
liquid (3.0.6)
104157
listen (3.0.6)
105158
rb-fsevent (>= 0.9.3)
106159
rb-inotify (>= 0.9.7)
107160
mercenary (0.3.6)
108161
mini_portile2 (2.1.0)
109-
minima (2.0.0)
110-
minitest (5.9.1)
162+
minima (2.1.1)
163+
jekyll (~> 3.3)
164+
minitest (5.10.2)
111165
multipart-post (2.0.0)
112166
net-dns (0.8.0)
113167
nokogiri (1.6.8.1)
114168
mini_portile2 (~> 2.1.0)
115-
octokit (4.4.1)
116-
sawyer (~> 0.7.0, >= 0.5.3)
169+
octokit (4.7.0)
170+
sawyer (~> 0.8.0, >= 0.5.3)
117171
pathutil (0.14.0)
118172
forwardable-extended (~> 2.6)
119-
public_suffix (1.5.3)
120-
rb-fsevent (0.9.8)
121-
rb-inotify (0.9.7)
122-
ffi (>= 0.5.0)
173+
public_suffix (2.0.5)
174+
rb-fsevent (0.10.2)
175+
rb-inotify (0.9.10)
176+
ffi (>= 0.5.0, < 2)
123177
rouge (1.11.1)
124178
safe_yaml (1.0.4)
125-
sass (3.4.22)
126-
sawyer (0.7.0)
127-
addressable (>= 2.3.5, < 2.5)
128-
faraday (~> 0.8, < 0.10)
129-
terminal-table (1.7.3)
130-
unicode-display_width (~> 1.1.1)
131-
thread_safe (0.3.5)
179+
sass (3.5.1)
180+
sass-listen (~> 4.0.0)
181+
sass-listen (4.0.0)
182+
rb-fsevent (~> 0.9, >= 0.9.4)
183+
rb-inotify (~> 0.9, >= 0.9.7)
184+
sawyer (0.8.1)
185+
addressable (>= 2.3.5, < 2.6)
186+
faraday (~> 0.8, < 1.0)
187+
terminal-table (1.8.0)
188+
unicode-display_width (~> 1.1, >= 1.1.1)
189+
thread_safe (0.3.6)
132190
typhoeus (0.8.0)
133191
ethon (>= 0.8.0)
134-
tzinfo (1.2.2)
192+
tzinfo (1.2.3)
135193
thread_safe (~> 0.1)
136-
unicode-display_width (1.1.1)
194+
unicode-display_width (1.3.0)
137195

138196
PLATFORMS
139197
ruby
@@ -143,4 +201,4 @@ DEPENDENCIES
143201
jekyll-redirect-from
144202

145203
BUNDLED WITH
146-
1.14.6
204+
1.15.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
layout: sip
3+
discourse: true
4+
title: SIP-NN - Right-Associative By-Name Operators
5+
---
6+
7+
**By: Stefan Zeiger**
8+
9+
## History
10+
11+
| Date | Version |
12+
|---------------|---------------|
13+
| Jul 12th 2017 | Initial Draft |
14+
15+
## Motivation
16+
17+
Scala allows the definition of right-associative by-name operators but the desugaring, as
18+
currently defined, forces the arguments, thus effectively making them by-value. This has
19+
been recognized as a [bug](https://github.com/scala/bug/issues/1980) since 2009.
20+
21+
## Motivating Examples
22+
23+
Apart from the examples mentioned in and linked to [scala/bug#1980](https://github.com/scala/bug/issues/1980),
24+
this has recently come up as a [problem for the collections library redesign](https://github.com/scala/collection-strawman/issues/127)
25+
for Scala 2.13.
26+
27+
Scala 2.12 has a `Stream` type with a lazy tail and a strict head element. Thanks to a clever
28+
[hack](https://github.com/scala/scala/blob/9ab72a204ff3070ffabc3c06f3d381999da43fcd/src/library/scala/collection/immutable/Stream.scala#L1115-L1133)
29+
right-associative by-name operators can work well enough for `Stream`:
30+
31+
scala> def f(i: Int) = { println("Generating "+i); i }
32+
f: (i: Int)Int
33+
34+
scala> f(1) #:: f(2) #:: f(3) #:: Stream.empty
35+
Generating 1
36+
res0: scala.collection.immutable.Stream[Int] = Stream(1, ?)
37+
38+
The `LazyList` type proposed for the new collections library is supposed to be lazy in the head and tail.
39+
This cannot be supported with the existing hack (which always forces the first element in the chain), so we need
40+
a proper fix at the language level.
41+
42+
## Design
43+
44+
The desugaring of binary operators is currently defined in the spec as:
45+
46+
> A left-associative binary
47+
> operation `e1 op e2` is interpreted as `e1.op(e2)`. If `op` is
48+
> right-associative, the same operation is interpreted as
49+
> `{ val x=e1; e2.op(x) }`, where `x` is a fresh name.
50+
51+
It should be changed to:
52+
53+
> A left-associative binary
54+
> operation `e1 op e2` is interpreted as `e1.op(e2)`. If `op` is
55+
> right-associative and its parameter is passed by name, the same operation is interpreted as
56+
> `e2.op(e1)`. If `op` is right-associative and its parameter is passed by value,
57+
> it is interpreted as `{ val x=e1; e2.op(x) }`, where `x` is a fresh name.
58+
59+
This means that all by-value parameters are still forced from left to right but by-name
60+
parameters are not forced anymore. They now behave the same way in operator syntax as they
61+
would when using standard method call syntax.
62+
63+
## Implementation
64+
65+
A complete implementation for Scala 2.13 is provided in [scala/scala#5969](https://github.com/scala/scala/pull/5969).
66+
67+
## Counter-Examples
68+
69+
No change of type inference semantics is implied by the new desugaring. In particular, all parameters to
70+
right-associative operators are still type-checked without an expected type in the current implementation.
71+
72+
It may be desirable to use an expected type, like for a method call, but that is orthogonal to this proposal
73+
and would necessarily apply equally to by-name and by-value parameters. In the case of overloaded
74+
operators it cannot be determined whether the parameter is by-name or by-value without type-checking the
75+
argument first.
76+
77+
## Drawbacks
78+
79+
- This constitutes a silent change in semantics for existing code. Since the current semantics are essentially
80+
broken the likelihood of affecting existing code negatively are low.
81+
82+
- Macros and tooling that works at the Scala AST level may need to be adapted to the new desugaring. This is also
83+
unlikely because the new desugaring produces currently legal Scala code that could have been manually written in
84+
the same way.
85+
86+
## Alternatives
87+
88+
As mentioned above, the current `Stream`
89+
[hack](https://github.com/scala/scala/blob/9ab72a204ff3070ffabc3c06f3d381999da43fcd/src/library/scala/collection/immutable/Stream.scala#L1115-L1133)
90+
can work around this problem in some cases but not all.

tutorials/tour/_posts/2017-02-13-mixin-class-composition.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ We would like to combine the functionality of `StringIterator` and `RichIterator
7171

7272
```tut
7373
object StringIteratorTest extends App {
74-
class Iter extends StringIterator(args(0)) with RichIterator
75-
val iter = new Iter
74+
class RichStringIter extends StringIterator(args(0)) with RichIterator
75+
val iter = new RichStringIter
7676
iter foreach println
7777
}
7878
```

tutorials/tour/_posts/2017-02-13-pattern-matching.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ In the `case Email(email, _, _) if importantPeopleInfo.contains(email)`, the pat
114114
You can match on the type like so:
115115
```tut
116116
abstract class Device
117-
case class Phone(model: String) extends Device{
117+
case class Phone(model: String) extends Device {
118118
def screenOff = "Turning screen off"
119119
}
120120
case class Computer(model: String) extends Device {

tutorials/tour/_posts/2017-02-13-traits.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ iterator.next() // prints 1
6060
This `IntIterator` class takes a parameter `to` as an upper bound. It `extends Iterator[Int]` which means that the `next` method must return an Int.
6161

6262
## Subtyping
63-
Subtypes of traits can be used where a the trait is required.
63+
Where a given trait is required, a subtype of the trait can be used instead.
6464
```tut
6565
import scala.collection.mutable.ArrayBuffer
6666

0 commit comments

Comments
 (0)