deathbeam / spoon

:ramen: Spoon is a programming language that runs blazingly fast, compiles to native code and works everywhere.
https://spoonlang.org
MIT License
56 stars 11 forks source link

Support for no parenthesis around conditions #9

Closed Peekmo closed 8 years ago

Peekmo commented 8 years ago

Hello,

With this PR, you'll not have to set parenthesis around conditions (for, while, if, elsif)

Hope you'll like it.

Regards, Peekmo

Peekmo commented 8 years ago

Wow, some files that I didn't touche has been change o.O Is it possible that the merge totally fucked ? I correct it

Edit : Done.

deathbeam commented 8 years ago

Hmm and do you tested to compile all examples and checked if output is correct?

deathbeam commented 8 years ago

But it is great addition, but what about multiline statements?

Peekmo commented 8 years ago

Yep, all output seems correct.

For multiline statements, question is opened. Perhaps just adding parenthesis when there's multiline ? Or like ruby, using a statement like "||" or "&&" at the end of the line (but I don't really like it) Or just, a "," after a line when there's multiline.

If any better idea, I'm open ;)

Peekmo commented 8 years ago

I added "," to manage multiline in conditions. You can find some example in examples/Conditions.rx

deathbeam commented 8 years ago

Awesome :) It still have some conflicts, so if you will fix them, I will merge this and so we can have more beautifull syntax :P

Peekmo commented 8 years ago

Done :)

deathbeam commented 8 years ago

And what will happen when I will write syntax like this?

if something && something.equals(5 +
  6) || something.equals(6 -
  8
Peekmo commented 8 years ago

It will fails, as in ruby. There's a syntax for multine and it must be respected.

It should be write like this

if something && something.equals(5 +,
  6) || something.equals(6 -,
  8
deathbeam commented 8 years ago

But that will compile to this:

if (something && something.equals(5 +,
  6) || something.equals(6 -,
  8) {

}

and that is not valid syntax. Anyway, I am going to merge it because I am going to write proper method to handle any multiline things.

Peekmo commented 8 years ago

No, I remove the ending "," of course.