Certainly the most severe usability problem in Effekt is rooted in the inability of distinguishing method calls from field access. This is a problem since method calls act on codata but field access acts on data — a distinction that must be made in the mind of the user (values are, computations do!).
In order to make Effekt more usable, it is imperative to distinguish these two constructs clearly so that the language is user-friendly to all its many users.
Description
Our inspiration for the syntax of field accesses is from user @judofyr on Twitter (https://twitter.com/judofyr/status/1685580152565055488) who suggested the natural use of ’s. This pull request implements this field access syntax and adds the necessary tests.
Example
Here’s an example of the new field access syntax:
record Car(model: String)
record Person(name: String, car: Car)
def main() = {
val Maxine = Person("Maxine", Car("Wartburg 353"))
println(Maxine’s name)
println(Maxine’s car)
println(Maxine’s car’s model)
}
Note that it’s naturally nestable: Maxine’s car’s model gets parsed as (Maxine’s car)’s model.
Future work
We should allow to use only the apostrophe ’ for instances where the identifier already ends with an s in order to allow a more properer and correcter English syntax:
// currently
Hans’s wife’s name
// in the future
Hans’ wife’s name
We also might want to think if we want to use ' or ’ for the apostrophe -- the former is probably familiar to programmers and thus easier to type, but the latter is slightly nicer.
Motivation
Certainly the most severe usability problem in Effekt is rooted in the inability of distinguishing method calls from field access. This is a problem since method calls act on codata but field access acts on data — a distinction that must be made in the mind of the user (values are, computations do!). In order to make Effekt more usable, it is imperative to distinguish these two constructs clearly so that the language is user-friendly to all its many users.
Description
Our inspiration for the syntax of field accesses is from user
@judofyr
on Twitter (https://twitter.com/judofyr/status/1685580152565055488) who suggested the natural use of’s
. This pull request implements this field access syntax and adds the necessary tests.Example
Here’s an example of the new field access syntax:
Note that it’s naturally nestable:
Maxine’s car’s model
gets parsed as(Maxine’s car)’s model
.Future work
We should allow to use only the apostrophe
’
for instances where the identifier already ends with ans
in order to allow a more properer and correcter English syntax:We also might want to think if we want to use
'
or’
for the apostrophe -- the former is probably familiar to programmers and thus easier to type, but the latter is slightly nicer.Enjoy the Assyrian New Year!