Skip to content

Infix function syntax #798

@DartBot

Description

@DartBot

This issue was originally filed by jesse.r...@gmail.com


I can comment for days about the weakness of language extension features most programming languages have which increases coding while reducing readability. Here goes.

Please add custom library operator functions. Examples will make my point. See if you can read the code easily and how it better self documents/mirrors the logic without classes or Lambdas. Compare it to just using dirty functions.

// defined at top level in library

operator between(num low, num high);
operator in(List values);

//Sample usage

 if ( customer.age between(18,65) ) {
     print("Contact this customer about an insurance policy.");
}
 
  if ( customer.status in(2,3,5) ) {
     print("Customer is a VIP, treat him good.");
  }

  var state = "NJ";

  if ( state in(states) ) {
    //state is a valid US state in states list.
  }

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-not-plannedClosed as we don't intend to take action on the reported issuetype-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions