Skip to content

Commit e37c89e

Browse files
committed
Elaborate on problems with "unbind", add hyperlinks to YT issues (#5)
1 parent 31e6ed4 commit e37c89e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Diff for: proposals/bound-callable-references.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Support "bound callable references" and "bound class literals".
1919
- It's painful to write lambdas every time
2020
- There's currently no way to reference an object member, which is sort of inconsistent with the fact that it's possible to reference static Java members
2121
- It's present in Java and its absence in Kotlin is rather inconvenient
22-
- >42 votes on KT-6947: Callable reference with expression on the left hand side
22+
- >42 votes on [KT-6947](https://youtrack.jetbrains.com/issue/KT-6947): Callable reference with expression on the left hand side
2323
2424
## Description
2525

@@ -102,10 +102,20 @@ Its `parameters` property doesn't have this parameter and the argument should no
102102

103103
## Open questions
104104

105-
- How to parse such expressions?
106105
- API for "unbinding" a reference
107-
- if unbound already, throw or return null, or provide both?
106+
- Information about the original receiver type is absent in the type of a bound reference, so it's unclear what signature will the hypothetical "unbind" function have.
107+
- One option would be an _unsafe_ "unbind" with a generic parameter which prepends that parameter to function type's parameter types:
108+
109+
```
110+
class O {
111+
fun foo() {}
112+
val bound: () -> Unit = this::foo
113+
val unbound: (O) -> Unit = this::foo.unbind<O>()
114+
}
115+
```
116+
- If unbound already, throw or return null, or provide both?
108117
- Should there be a way to obtain an unbound reference to an object member?
118+
- May be covered with the general API for unbinding a reference, or may be approached in a completely different way (with a language feature, or a library function).
109119

110120
## Alternatives
111121

@@ -121,7 +131,7 @@ We could try resolve type in LHS first, and only then try expression. This has t
121131
- `::<member>`, `::class`.
122132
For a class member, empty LHS of a callable reference may mean `this`.
123133
Rationale: inside the class you can call `member()`, why not `::member` then?
124-
- `super::<member>` (KT-11520)
125-
- Support references to member extensions (KT-8835)
134+
- `super::<member>` ([KT-11520](https://youtrack.jetbrains.com/issue/KT-11520))
135+
- Support references to member extensions ([KT-8835](https://youtrack.jetbrains.com/issue/KT-8835))
126136

127137
All these features can be safely introduced later.

0 commit comments

Comments
 (0)