Skip to content

Commit a5bac26

Browse files
committed
Drop structural instances from docs
Structural instances (i.e. use `with` instead of `new` for anonymous classes) are not part of this PR.
1 parent 8c8a8d2 commit a5bac26

File tree

1 file changed

+0
-57
lines changed

1 file changed

+0
-57
lines changed

docs/docs/reference/other-new-features/creator-applications.md

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -41,60 +41,3 @@ caused numerous problems, including
4141
- overloading ambiguities
4242
- overriding errors
4343
- shadowing of user-defined `apply` methods by more specific auto-generated ones.
44-
45-
### Structural Instances
46-
47-
Structural instances are a replacement for anonymous classes.
48-
Example:
49-
```scala
50-
trait Person {
51-
def name: String
52-
def age: Int
53-
}
54-
// Anonymous class
55-
new Person {
56-
def name = "Lara"
57-
def age = 22
58-
}
59-
// Structural instance
60-
Person with {
61-
def name = "Lara"
62-
def age = 22
63-
}
64-
```
65-
A structural instance expression consists of the implemented class(es) or trait(s) (`Person` in the code above), followed by the reserved word `with` and definitions that implement or override class members.
66-
67-
Structural instances can be have more than one parent. In this case,
68-
69-
70-
### Translation
71-
72-
Structural instances map to expressions with `new` as follows.
73-
74-
A structural instance with a single parent `T` and empty definitions
75-
```scala
76-
T(args) with { }
77-
```
78-
maps to
79-
```
80-
new T(args)
81-
```
82-
83-
A structural instance with multiple parents and/or non-empty definitions
84-
85-
```scala
86-
T(args1) with U(args2) with { defs }
87-
```
88-
maps to
89-
```
90-
{ class $anon extends T(args1), U(args2) { defs} ; new $anon }
91-
```
92-
This means that every instance creation expression can be written without `new`, using either a creator application or, where this is not possible, a structural instance expression.
93-
94-
### Syntax
95-
96-
```
97-
Expr1 ::= ... | StructuralInstance
98-
StructuralInstance ::= ConstrApp {‘with’ ConstrApp} ‘with’ TemplateBody
99-
```
100-

0 commit comments

Comments
 (0)