Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [epsilon-dev] Ternary operator now available

Hi Antonio,

I have already added it to the Epsilon book :) Nesting only works if parentheses are used, otherwise it won't parse. I didn't explicitly make it that way, but it's a convenient side-effect which forces users to be unambiguous in their _expression_. You can nest arbitrarily deep, mix and match ':' and 'else' and it qll works as expected.

Thanks,
Sina


On Sat, 18 Apr 2020, 08:54 Antonio Garcia-Dominguez, <agarcdomi@xxxxxxxxx> wrote:
Hi Sina,

Thanks for this! How does it work in terms of nesting / associativity?

Remember that we'll need to have it documented in the Epsilon book as well ;-).

Kind regards,
Antonio

On Sat, 11 Apr 2020 at 16:54, Sina Madani <sinadoom@xxxxxxxxxxxxxx> wrote:

Hi everyone,

 

Just to let you know that I have added a ternary operator to EOL (as requested in [1]), which should make programs more concise (especially EGL templates). This is a more advanced ternary operator than is available in Java: you do not have to assign the result to a variable or return it, but can use it anywhere you would any other _expression_. You can also use the “else” keyword in place of the colon to separate the true and false expressions, which is perhaps more readable for those less familiar with ternary syntax.

I also considered the Python-style ternary (which is of the form <exprIfTrue> if <exprCondition> else <exprIfFalse>) but given that EOL is heavily Java-inspired I didn’t implement this for consistency (also a matter of taste, but the Python style ternary is less intuitive to a lot of programmers, though perhaps it’s more readable for non-programmers).

 

Thanks,

Sina

 

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=514986

_______________________________________________
epsilon-dev mailing list
epsilon-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/epsilon-dev


--
Antonio Garcia-Dominguez
_______________________________________________
epsilon-dev mailing list
epsilon-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/epsilon-dev

Back to the top