What is a parameter list in Pascal functions?

A parameter list is a list of names and types of parameters that a function/procedure accepts. These parameters are accessible inside the function.

In Pascal, when a parameter list is being declared, the parameters of the same data type are grouped.

Syntax

function funcName(paramGrp1; paramGrp2; ...) : returnType;

In the above snippet of code, the funcName is replaced by the function’s name. Then, the parameter list is passed in parenthesis. Each paramGrp in the parameter list is separated by a semi-colon and has the following syntax:

[const/var/out] paramName1, paramName2... paramNameN : dataType

Here, paramName is the parameter’s name by which it will be accessible in the function body. We can write the names of multiple parameters if they have the same data type. Then, we write a :, followed by the data type of those parameters.

The keywords const, var, and out are optional. These are used to declare constant, variable, or out parameters, respectively. The absence of any of these keywords means that the parameter is a value parameter. If we wish to pass a different parameter type with the same data type, we must declare it into a separate parameter group.

The following table provides a brief description of the types of parameters:

Type

Description

const

A constant parameter. Its value can not be changed inside the function.

var

A variable parameter. It is passed by reference. The changes in this parameter are also reflected outside the function.

out

An out parameter. These do not have an initial value and are used to export a value out of the function.

value [default]

A value parameter. It is passed to the function by value. The changes made in it are not reflected outside the function body.

Detailed descriptions about the types of parameters can be found here.

Example

Consider the following snippet of code which declares a function:

Program ParamList(output);
function myFunction(const str1, str2: string ; str3: string ; var int1, int2: integer) : integer;
begin
writeln('Following are the constant parameters. Their values can not be changed inside the function');
writeln('str1: ', str1);
writeln('str2: ', str2);
writeln();
writeln('Following is the value parameter. Changes made in it are not refelcted outside the function body:');
writeln('str3: ', str3);
writeln();
writeln('Following ar variable parameters. Changes made in these are refeclted outisde the function body as well: ');
writeln('int1: ', int1);
writeln('int2: ', int2);
end;
var
str1 : string = 'This is str1';
str2 : string = 'This is str2';
str3 : string = 'This is str3';
int1 : integer = 5;
int2 : integer = 10;
begin
myFunction(str1,str2,str3,int1,int2);
end.

In the above snippet of code, a function named myFunction is being declared.

In the parameter list, we passed:

  • two constant parameters of type string named str1 and str2.
  • a value parameter of type string named str3.
  • two variable parameters of type integer named int1 and int2.

Inside the function body, each parameter’s type and value are being printed, along with its primary characteristic.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved