The difference is actually:
1. Pascal has call by value and call by reference.
2. C only has call by value.
Because of limitation 2, C programmers use the pointer trick to pass the
address of a variable so it can be changed inside the routine, example:
1. C call by value (default):
void test( int a )
{
a = 5; // after routine exists, value is lost.
}
test( b );
2. C call by value (reference trick):
void test( int *a ) <- pointer to variable of integer trick.
{
*a = 5;
}
test( &b ); // <- address of variable trick.
For noobies/novice programmers this makes C a bad language since
noobies/novice programmers are still learning to design software codes and
will often need to change call by value to call by reference or vice versa
and then it becomes a hurdle to change all these call sites, not mention
confusion.
For experienced programmers it's also a reall burden to use * everywhere and
& everywhere, everywhere reference comes into play.
Passing real pointers and working with them becomes even more tricky and
requires even more stars/asterixes.
A very bad problem which was easily solved in pascal:
procedure test( var a : integer );
begin
a := 5;
end;
test( a );
^ No stupid symbols needed ! ;) Much user friendly and pretty much does the
same thing.
Why make things more difficult then absolutely necessary huh ?! ;) :) =D
Only thing I can imagine is very very very maybe it's easier to write a
"call by value compiler" than a "call by reference compiler" ?!? But does
sound a bit like bullshit to me ?! ;) :)
Bye,
Skybuck =D
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel