mint-lang / mint

:leaves: A refreshing programming language for the front-end web.
https://mint-lang.com
BSD 3-Clause "New" or "Revised" License
4.06k stars 141 forks source link

Relax whitespace rules around operators #637

Open farism opened 1 year ago

farism commented 1 year ago

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 commented 1 year ago

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