Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Call oddities: &Test() vs &Test vs Test

0 views
Skip to first unread message

Skybuck Flying

unread,
Oct 4, 2009, 12:10:20 PM10/4/09
to
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.


Skybuck Flying

unread,
Oct 4, 2009, 2:34:17 PM10/4/09
to

"Skybuck Flying" <Blood...@hotmail.com> wrote in message
news:918bb$4ac8c8d9$d53372a9$18...@cache1.tilbu1.nb.home.nl...

Typo corrected:

Currently the situation is reversed, to acquire a pointer to a routine in C

0 new messages