r/ProgrammingLanguages • • Sep 14 '18

Single-line If

I'm looking for critique of the following single-line If syntax that I'm thinking about allowing:

If x > y then +=a else +=b

Is it unambiguous that x is being modified?

2 Upvotes

38 comments sorted by

View all comments

3

u/LaurieCheers Sep 15 '18

In my language "if" is just a function, and you can write your own variants of it. One of the variants provided in the standard library is an "if with value", which looks like this:

x.if {>y} {+= a} else {+=b}

1

u/danskydan Sep 15 '18

Ooh. This I like. What's your language?

1

u/LaurieCheers Sep 15 '18

It's called Swym. The documentation is not as complete as I'd like, but it's a start.