progn, prog1

progn, prog1 — group several statements into one expression.

Syntax

progn {!statement [!statement] ...}
prog1 {!statement [!statement] ...}

		

Arguments

statement

Any valid Gamma statement.

Returns

progn: the return value of the last statement.

prog1: the return value of the first statement.

Description

These two syntactical elements are not statements, but they transform a group of one or more statements into a single Gamma expression. The value of the resulting expression is the return value of the last statement for progn or the first statement for prog1. This is useful for performing complex actions where only a single expression is permitted, such as in a callback. No new scope is entered for a progn or a prog1.

[Note]

The syntax of these unique elements uses curly braces { }, but don't confuse them with statements. They behave exactly like expressions.

Example

Gamma> a = 2;
2
Gamma> b = 5;
5
Gamma> progn{a = 3; princ("a: ",a,"\n"); c = a + b; princ("c: ",c,"\n");};
a: 3
c: 8
t
Gamma> string( prog1{a = 5; b = 1;} );
"5"
Gamma> a;
5
Gamma> b;
1
Gamma>