Friday, February 19, 2016

Basic Structure for our discussions

When reviewing programming, we will need a common ground to work with.  The following definitions will apply:

Comments will start with '//'
Parameters, will use all caps for CONSTANTS or begin with a lowercase letter for a variable
Statement blocks will begin with '{' and end with '}'
Types will be defined as all caps for predefined types like 'NUMBER' or preceded with an underscore for a composite type like '_Array'
Optional items will be enclosed in '[' and ']'
Repeated items will be denoted by ', ...'
Function calls will be formatted 'Name( [value, ...] )'
Function definitions will be formated '[TYPE] [returnValue] Name( [[TYPE] value, ...] )' followed by a statement block.
BOOLEAN is a type with TRUE and FALSE defined.

Sample code:

//Function Not returns the opposite of the boolean parameter
//Simple form
BOOLEAN Result Not( BOOLEAN param )
{
    IF( param = TRUE )
    THEN Result = FALSE
    ELSE Result = TRUE
}

//Function And returns TRUE when both parameters are TRUE
//Nested block form
BOOLEAN And( param1, param2 )
{
   IF( Not( Param1 IS BOOLEAN ) )
   THEN Result = FALSE
   ELSE
   {
      IF( NOT( Param2 IS BOOLEAN ) )
      THEN Result = FALSE
      ELSE
      {
         IF( Param1 = Param2 )
         THEN Result = Param1
         ELSE Result = FALSE
      }
   }
   RETURN Result
}

No comments:

Post a Comment