Skip to content

Commit 9a844a6

Browse files
committed
Adjustments to layout, + syncing with Josh.
1 parent d60e3c4 commit 9a844a6

File tree

7 files changed

+100
-189
lines changed

7 files changed

+100
-189
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_site

_layouts/default.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252
<div class="row">
5353
<h1>{{ site.title }}</h1>
5454
{% if page.title %}<h1>{{ page.title }}</h1>{% endif %}
55-
<div class="span12">
55+
<div class="span10">
5656
{{ content }}
57-
{% if page.disqus == true %}#DISQUS!!#{% include disqus.txt %}{% endif %}
57+
{% if page.disqus == true %}{% include disqus.txt %}{% endif %}
5858
</div>
5959
{% if page.type == 'sip' %}
60-
<div class="span4">
60+
<div class="span6">
6161
{% include allsids.txt %}
6262
</div>
6363
{% endif %}

sips/draft/_posts/2011-10-12-implicit-classes.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

sips/draft/_posts/2011-10-12-inline-classes.md

Lines changed: 0 additions & 162 deletions
This file was deleted.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
layout: default
3+
type: sip
4+
title: SIP-13 - Implicit classes
5+
---
6+
7+
This SIP is based on [this pre-draft](https://docs.google.com/document/d/1k-aGAGmbrDB-2pJ3uDPpHVKno6p-XbnkVHDc07zPrzQ/edit?hl=en_US).
8+
9+
Material adapted from [http://jorgeortiz85.github.com/ImplicitClassSIP.xhtml](http://jorgeortiz85.github.com/ImplicitClassSIP.xhtml) which is Copyright © 2009, Jorge Ortiz and David Hall
10+
11+
## Abstract ##
12+
13+
A new language construct is proposed to simplify the creation of classes which provide _extension methods_ to another type.
14+
15+
## Description ##
16+
17+
The `implicit` keyword will now be allowed as an annotation on classes. Classes annotated with the `implicit` keyword are refered to as _implicit classes_.
18+
19+
An implicit class must have a primary constructor with *exactly* one argument in its first parameter list. It may also include an additional implicit parameter list. An implicit class must be defined in a scope where method definitions are allowed (not at the top level). An implicit class is desugared into a class and implicit method pairing, where the implciit method mimics the constructor of the class.
20+
21+
The generated implicit method will have the same name as the implicit class. This allows importing the implicit conversion using the name of the class, as one expects from other implicit definitions.
22+
For example, a definition of the form:
23+
24+
{% highlight scala %}
25+
implicit class RichInt(n: Int) extends Ordered[Int] {
26+
def min(m: Int): Int = if (n <= m) n else m
27+
...
28+
}
29+
{% endhighlight %}
30+
31+
will be transformed by the compiler as follows:
32+
33+
{% highlight scala %}
34+
class RichInt(n: Int) extends Ordered[Int] {
35+
def min(m: Int): Int = if (n <= m) n else m
36+
...
37+
}
38+
implicit final def RichInt(n: Int): RichInt = new RichInt(n)
39+
{% endhighlight %}
40+
41+
Annotations on `implicit` classes default to attaching to the generated class *and* the method. For example,
42+
43+
{% highlight scala %}
44+
@bar
45+
implicit class Foo(n: Int)
46+
{% endhighlight %}
47+
48+
will desugar into:
49+
50+
{% highlight scala %}
51+
@bar implicit def Foo(n: Int): Foo = new Foo(n)
52+
@bar class Foo(n:Int)
53+
{% endhighlight %}
54+
55+
The `annotation.target` annotations will be expanded to include a `genClass` and `method` annotation. This can be used to target annotations at just the generated class or the generated method of an implicit class. For example:
56+
57+
{% highlight scala %}
58+
@(bar @genClass) implicit class Foo(n: Int)
59+
{% endhighlight %}
60+
61+
will desugar into
62+
63+
{% highlight scala %}
64+
implicit def Foo(n: Int): Foo = new Foo(n)
65+
@bar class Foo(n: Int)
66+
{% endhighlight %}
67+
68+
69+
## Specification ##
70+
71+
No changes are required to Scala's syntax specification, as the relevant production rules already allow for implicit classes.
72+
73+
LocalModifier ::= ‘implicit’
74+
BlockStat ::= {LocalModifier} TmplDef
75+
TmplDef ::= [‘case’] ‘class’ ClassDef
76+
77+
The language specification (SLS 7.1) would be modified to allow the use of the implicit modifier for classes. A new section on Implicit Classes would describe the behavior of the construct.
78+
79+
## Consequences ##
80+
81+
The new syntax should not break existing code, and so remain source compatible with existing techniques.
82+
83+

sips/pending/_posts/2011-10-13-uncluttering-control.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ disqus: true
55
title: SIP-12 Uncluttering Scala’s syntax for control structures.
66
---
77

8-
__Motivation__: The more Scala code I write the more I get tripped up by the need to write conditions in if-then-else expressions and other control constructs in parentheses. I normally would not advocate syntax changes at this level, except that this has been the single syntax decision that feels worse for me the longer I use it.
8+
__Martin Odersky__
99

10-
## Part 1: `if` ##
10+
__first submitted 13 October 2011__
11+
12+
13+
## Motivation ##
14+
15+
The more Scala code I write the more I get tripped up by the need to write conditions in if-then-else expressions and other control constructs in parentheses. I normally would not advocate syntax changes at this level, except that this has been the single syntax decision that feels worse for me the longer I use it.
16+
17+
## Part 1: if ##
1118

1219
Having to write parentheses is an unfortunate inheritance from C via Java. It makes code more cluttered than it could be. In C/C++/Java this was no big deal, but because Scala is much cleaner syntactically than these languages it starts to stick out like a sore thumb. This in particular because only one form of `if` comes with parentheses; if you use an if as a filter in a for expression or as a guard in a pattern, no parentheses are required.
1320

@@ -28,7 +35,7 @@ So, here is the proposal (for Scala 2.10):
2835

2936
Once we have dealt with if, we should do the same thing with while, do-while and for.
3037

31-
## Part 2: `do-while` ##
38+
## Part 2: do-while ##
3239

3340
do-while is easy. Simply do the following:
3441

@@ -40,7 +47,7 @@ do-while is easy. Simply do the following:
4047

4148
While loops and for loops are more tricky.
4249

43-
## Part 3: `while` ##
50+
## Part 3: while ##
4451

4552
For while loops:
4653

@@ -72,7 +79,7 @@ For while loops:
7279

7380
4. In Scala 2.12: Drop the restriction introduced in 2.10. Conditions in a `while-do` can now be arbitrary expressions including with parentheses at the outside.
7481

75-
## Part 4: `for` ##
82+
## Part 4: for ##
7683

7784
For-loops and for expressions can be handled similarly:
7885

@@ -117,3 +124,4 @@ The new syntax removes more cases than it introduces. It also removes several ha
117124

118125

119126

127+

sips/sip-list.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ type: sip
44
title: List of SIPs
55
---
66

7-
### Draft SIPs ###
8-
<ul class="post-list">
9-
{% for post in site.categories.draft %}
10-
<li><a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a> <span class="date">( {{ post.date | date: "%b %Y" }} )</span></li>
11-
{% endfor %}
12-
</ul>
13-
147
### Completed SIPs ###
158
<ul class="post-list">
169
{% for post in site.categories.completed %}

0 commit comments

Comments
 (0)