Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Call oddities: &Test() vs &Test vs Test

Reply
Thread Tools

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

 
 
Skybuck Flying
Guest
Posts: n/a
 
      10-04-2009
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.


 
Reply With Quote
 
 
 
 
Skybuck Flying
Guest
Posts: n/a
 
      10-04-2009

"Skybuck Flying" <(E-Mail Removed)> wrote in message
news:918bb$4ac8c8d9$d53372a9$(E-Mail Removed)1.n b.home.nl...
> 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


Typo corrected:

Currently the situation is reversed, 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.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
test test test richard Computer Support 3 01-24-2007 05:18 AM
TEST TEST Test...Blah Blah Blah generalbatguano@pacbell.net Computer Support 2 09-15-2006 03:47 AM
TEST TEST Test...Blah Blah Blah Generalbatguano@pacbell.net Computer Support 6 09-13-2006 01:53 AM
TEST TEST TEST Gazwad Computer Support 2 09-05-2003 07:32 PM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments