Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » B3 » include an "else" statement?
include an "else" statement? [message #492015] Sat, 17 October 2009 03:38
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
One think I brought up in the sample.b3 was if we should have an "else"
clause. It is alrady possible to write two when statements where the
second is the reverse of the first. There are several ways to acheive this:

- use a property "if" , and simply have a second property called "else"
have the vaue "!if", and then write when(if) {} when(else).

- just negate the logic when(a == b) {} when (a != b) {}. But it is
really tedious to do so with a long chain of calls, or when using
pattern matching. It is also error prone as a developer may forget to
change the negated variant and not understand that it is supposed to
represent an else statment.

Do you think we should support the following?:
when() SOMETHING
else SOMETHING ELSE

I can also see that a switch would be useful:

switch(val) {
when(x) SOMETHING;
when(y) SOMETHING;
default SOMETHING;
}

As the most common use of 'when' will probably be to produce different
results for different target.* properties. A switch would save the user
from having to type "target.* ==" multiple times.

I am ambivalent on both.

Maybe it is better to have better support for handling sets of
properties - i.e. compare many properties at once.

Or all of them ? (See, told you I was ambivalent :) )

What do you think.
- henrik
Previous Topic:include an "else" statement?
Next Topic:suggestion for changes to advice expressions
Goto Forum:
  


Current Time: Mon Sep 23 21:35:29 GMT 2024

Powered by FUDForum. Page generated in 0.03360 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top