S
Skybuck Flying
Hello,
There are some call oddities in both languages: Delphi and C.
The purpose of a language is to tell the computer what to do... but ofcourse
a language is also for us humans to understand what is written/ment.
Therefore it would be a nobble cause to try and make the language as clearly
as possible.
I now present to you some "cases" where both languages Delphi and C fail in
this regard:
Case 1 (Delphi):
IdentifierA = IdentifierB;
From this single line of code it cannot be said if IdentifierB is a field or
a routine call yet it's still allowed to be written in Delphi. Correct
translation from Delphi to C/C++ without more information, is therefore not
possible.
Case 2 (C):
IdentifierB;
From this single line of code it cannot be said if IdentifierB is a field or
a routine yet it's still allowed to be written in C. If IdentiferB is a
routine then no call will happen, which is inconsistent with Delphi and
could lead to bugs when translating from Delphi to C/C++. Correct
translation from Delphi to C/C++ without more information, is therefore not
possible.
Case 3 (Delphi):
if (Identifier) then
From this single line of code it cannot be said if Identifier is a field or
a routine call yet it's still allowed to be written in Delphi. Correct
translation from Delphi to C/C++ without more information, is therefore not
possible.
The question is can the situation be improved ?
A possible solution could be to make the () for routine calls mandatory.
Also for acquiring a pointer to a routine the () could be mandatory.
Instead of writing:
IdentifierA = &IdentifierB;
It would become:
IdentifierA = &IdentifierB();
Which would return the address of the routine IdentifierB.
IdentifierA = &IdentifierB()();
Would return the address of the second routine which is being called by the
function pointer returned by the first routine.
(Note: Delphi does not have this functionality: Calling a returned function
pointer immediatly).
Currently the situation is reserved to acquire a pointer to a routine in C
the () must not be written:
IdentifierA = &Identifier;
The question is:
Would any functionality in C be lost if this is changed to described as
above:
IdentifierA = &Identifier();
?
Bye,
Skybuck.
There are some call oddities in both languages: Delphi and C.
The purpose of a language is to tell the computer what to do... but ofcourse
a language is also for us humans to understand what is written/ment.
Therefore it would be a nobble cause to try and make the language as clearly
as possible.
I now present to you some "cases" where both languages Delphi and C fail in
this regard:
Case 1 (Delphi):
IdentifierA = IdentifierB;
From this single line of code it cannot be said if IdentifierB is a field or
a routine call yet it's still allowed to be written in Delphi. Correct
translation from Delphi to C/C++ without more information, is therefore not
possible.
Case 2 (C):
IdentifierB;
From this single line of code it cannot be said if IdentifierB is a field or
a routine yet it's still allowed to be written in C. If IdentiferB is a
routine then no call will happen, which is inconsistent with Delphi and
could lead to bugs when translating from Delphi to C/C++. Correct
translation from Delphi to C/C++ without more information, is therefore not
possible.
Case 3 (Delphi):
if (Identifier) then
From this single line of code it cannot be said if Identifier is a field or
a routine call yet it's still allowed to be written in Delphi. Correct
translation from Delphi to C/C++ without more information, is therefore not
possible.
The question is can the situation be improved ?
A possible solution could be to make the () for routine calls mandatory.
Also for acquiring a pointer to a routine the () could be mandatory.
Instead of writing:
IdentifierA = &IdentifierB;
It would become:
IdentifierA = &IdentifierB();
Which would return the address of the routine IdentifierB.
IdentifierA = &IdentifierB()();
Would return the address of the second routine which is being called by the
function pointer returned by the first routine.
(Note: Delphi does not have this functionality: Calling a returned function
pointer immediatly).
Currently the situation is reserved to acquire a pointer to a routine in C
the () must not be written:
IdentifierA = &Identifier;
The question is:
Would any functionality in C be lost if this is changed to described as
above:
IdentifierA = &Identifier();
?
Bye,
Skybuck.