Dismiss
InnovationQ will be updated on Sunday, Oct. 22, from 10am ET - noon. You may experience brief service interruptions during that time.
Browse Prior Art Database

Default FINALLY Clause for Loop Constructs in Programming Languages

IP.com Disclosure Number: IPCOM000035580D
Original Publication Date: 2005-Jan-25
Included in the Prior Art Database: 2005-Jan-25
Document File: 2 page(s) / 39K

Publishing Venue

IBM

Abstract

Loops are often used to search tables of values in an application program. When the value is found a BREAK is issued to end the loop. Sometimes though no value is found and the loop terminates normally. The programmer then must provide some conditional logic to determine which loop terminating condition occurred.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 100% of the total text.

Page 1 of 2

Default FINALLY Clause for Loop Constructs in Programming Languages

The core idea is to provide a FINALLY clause to the FOR or WHILE loop constructs in a programming language for the purpose of executing the END of LOOP logic. Other programming constructs have default clauses:

IF has the ELSE clause

SWITCH has the DEFAULT clause TRY has the FINALLY clause

Why not have one for the FOR, WHILE and DO...WHILE loop constructs?

An example of the current coding strategy used by programmers:

int empID;

for (empID=0 ; empID<empMAX; empID++) { if(name==empName[empID] ) break; }

if ( empID == empMAX ) { print "ERROR no employee was found. Employee ID set to (-1)"; empID=-1;

}

...code continues using empID value assigned by loop construct...

An example of the same code with the proposed FINALLY clause in use:

int empID;

for (empID=0 ; empID<MAX; empID++) { if(name==empName[empID] ) break; } finally { print "ERROR no employee was found. Employee ID set to (-1);" empID=-1 }

...code continues using empID value assigned by loop construct...

1

Page 2 of 2

2