dart-lang / dart-lang/language

Infix function

Open
#1,087 4 comments 32 reactions 0 assignees View on GitHub
feature
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

Being able to add an `infix` keyword before methods in order to be able to use them like `a method b` instead of `a.method(b)` would make the syntax cleaner in cases where both `a` and `b` have the same role/importance in the operation, such as in most mathematical forms.
In contrast to #607, this feature request doesn't aim to allow any arbitrary character as operators but instead only the usual method identifiers. Here are some examples of how the syntax could be used:

- Dot products like `vec dot otherVec` instead of `vec.dot(otherVec)`.
- Ranges like `1 to 5` or `2 until 5` instead of `1.to(5)` and `2.until(5)`, just like in Kotlin.

Contributor guide

Open the contributing guide

Research direction

Start with the proposal in this issue and compare its scope with #607, focusing on the `infix` keyword and the demonstrated method-call forms. Done would require a settled language-design decision and corresponding specification work; the issue names no files or tests to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.