I don't hate you for hating Pascal as I don't exactly like it either but knowing it is a good thing as it does teach the constructs of most languages fairly easily. It's just that it is a bit too wordy for my style.

Originally Posted by
pija
Could you tell me what is the difference between a procedure with result as an argument and a function?
Why yes I can 
C++ Code:
void SomeProcedure(int &Value) //Procedure with return type as Parameter. Passed by Reference.
{
Value = 0;
}
Pascal Code:
Procedure SomeProcedure(var Value: Integer); //Pass by Reference as well..
begin
Value := 0;
end;
The difference between a Procedure with a value passed by reference vs a function that returns a Value is "Copying".
Take this for example:
C++ Code:
std::vector<int> SomeFunction()
{
return {1, 2, 3, 4, 5}; //same as std::vector<int> Result = {1, 2, 3, 4, 5}; return Result; Notice the temporary being created?
}
int main()
{
std::vector<int> SomeValue = SomeFunction(); //At this line, SomeFunction creates a vector.. When assigned, the value is COPIED to SomeValue.
//In the end, two vectors were created. The temporary one inside the function, and the one we created to be assigned to.
}
//Now see this:
void SomeProcedure(std::vector<int> &Value)
{
Value = {1, 2, 3, 4, 5};
}
int main()
{
std::vector<int> Value; //One vector is created..
SomeProcedure(Value); //Modifies that vector to hold the returned values.. No copying done.
}
Pascal Code:
Function SomeFunction: TIntegerArray;
begin
SetLength(Result, 5);
Result := [1, 2, 3, 4, 5];
end;
//main.
var
Value: TIntegerArray;
begin
Value := SomeFunction; //SomeFunction Creates an array of 5 values. The assignment operator copies that array to "Value" variable.
end.
Procedure SomeProcedure(var Value: TIntegerArray)
begin
SetLength(Value, 5);
Value := [1, 2, 3, 4, 5]; //Not sure if I can do that.. Might have to do Value[0] = 1; Value[1] = 2; etc..
end;
//main.
var
Value: TIntegerArray;
begin
SomeProcedure(Value); //No copying done.. Only modifying..
end.
The above pascal code may not be compilable.. See my inline-comment. Anyway, you get the idea.
Functions that return a result usually "Copy" whereas a function taking a result by reference simply modifies.
You use return types where you simply do not want to modify the original and pass by reference where you want to save memory/speed.
C++x11 gets rid of this copying with R-Value reference where it uses std::move on a Temporary object such that no copying is done, but rather the object/resource can be moved to the returned value rather than copied.
MoveConstructs and CopyConstructors.
I'm unaware of this being done in pascal but that's what PassByReference does. Java has PassByValueReference. It is not the same. PassByValueReference simply passes a "Copy" of a "Reference" such that the original Reference is never lost but the object can be modified through accessor/mutator methods {get/set} but the actual reference itself may not be modified.