User Tools

Site Tools


01_user_documentation:07_rgg_xl:02_xl:09_java_addition:xl_expression_list

Expression list

In RGG, for Java as well as XL blocks it is possible to combine several expressions in one expression, using brackets and separating them by comma. The expressions will then be executed in order from left to right, and the last one on the right defines the return value of the surrounding expression list.

The syntax is:

// on an object 
OBJECT.(EXPR, EXPR, ... ); 
// to pipe line method calls
(EXPR, EXPR, ... ); 

An EXPR can be almost any feature of RGG:

  • Variable declaration
  • Variable assignment/change
  • Java/RGG functions
  • Ternary conditional operator

Note that:

  • The method call can be methods from either the current scope, or the scope of the OBJECT.
  • The variable declarations can be used in any of the expression on their right.

Apply on objects

For instance:

public void run ()
{
	// in a Java block  
	// at object creation: 
	Sphere s = new Sphere().( setShader(GREEN), double area = getSurfaceArea(), println(area) ); 
 
	// in a XL block
			// at node creation
	[ Node ==> sp:Sphere.(setShader(BLUE)) ,  
				// on an existsing node
				sp.(setRadius(5)) ; ]
}

Variable handling

A simple example of an expression list that combines several mathematical steps in one expression is the following, which sets the value of a to 6.

int a = (int i=1,i++,i*3);

The variable i stays in the scope of the expression list and can be used by the two following expressions but not outside of the brackets.

Ternary conditional operator

An Ternary conditional operator is in simple terms an inline 'if else' expression, using the following syntax to write for instance: if x then b else c with a ? b : c. With a being a boolean condition and b and c being expressions.

01_user_documentation/07_rgg_xl/02_xl/09_java_addition/xl_expression_list.txt · Last modified: 2025/09/05 15:21 by gaetan