mint icon indicating copy to clipboard operation
mint copied to clipboard

Relax whitespace rules around operators

Open farism opened this issue 2 years ago • 1 comments

The compiler could allow all of the following syntax

let a=2
let b = a|>Number.toString
let neq = a!=1
let eq = foo==2
let lte = a<=3
let lt = a<3
let gte = a>=1
let gt = a>1
let plus = a+1
let multiply = a*2
let divide = a/2
let mod = a%2==0
let exp = 2**3
let and = a==2&&a==2
let ortest = a==1||a==2
let true = ! false

Special consideration needs to be taken for

- because - is ambiguous with negative values or because it the characters "or" can be used in variable names

In addition to relaxing the syntax, if there is no whitespace surrounding an operator, then whitespace should be inserted by the formatter. Not sure if that should be a separate issue.

farism avatar Sep 03 '23 12:09 farism

Related https://github.com/mint-lang/mint/issues/397

farism avatar Sep 03 '23 13:09 farism