wren-lang / wren

The Wren Programming Language. Wren is a small, fast, class-based concurrent scripting language.
http://wren.io
MIT License
6.83k stars 545 forks source link

Alternate syntax without newlines #833

Open Gouwi opened 3 years ago

Gouwi commented 3 years ago

Wren is great : not only the language is well designed, but the implementation is concise and efficient.

It brings me joy.

However, i cannot stand the newline syntax as described here. So i started digging the code to research a way to implement an alternate (compatible ?) syntax which would allow to write Wren code on one line with, say, semicolons.

I created this thread for two reasons :

mhermier commented 3 years ago

Both syntax are fine, and have pro and cons. One issue I see is that it will remove the one line function return, requiring an explicit return.

Appart from that, I don't think it will be accepted in main branch because some of the pros of the current syntax makes it more interesting than the comma separated expression syntax.

But if you are really motivated, make your own branch, converting the compiler should be quite trivial and straight forward, since it means mostly replacing checks for blanks/new line by ignoring blanks/expecting ';', with some corner cases. If you want to support both syntax, I think the main corner cases is the one line return function I pointed out earlier.