BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Syntax question

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design
View previous topic :: View next topic  
Author Message
Wouter Devos [XLent Solut
Guest





PostPosted: Thu Nov 20, 2003 9:50 am    Post subject: Syntax question Reply with quote



Hi,

I have some syntax problem which is not clear to me.

The interface section of the unit is like

TDetailController = class (TXLSFormController)
protected
.......
procedure mGridPageDown (aObject: TObject); virtual;
........
public

........
end;

In the implementation section, due to a 'mistake' i had

procedure TDetailController.mGridPageDown;
begin
if Assigned (aObject) and (aObject is TcxGridDBTableView) then

TXLSGridTableController(TcxGridDBTableView(aObject).Controller).FocusNextPag
e(True);
end;

This compiles and runs fine. When renaming aObject to aaObject in the
implementation section, I get an error (looks normal).
When renaming aObject to aaObject in the interface and implemenation section
it runs fine again.

It looks like there is no need to specify the arguments here in the
implementation section.
Why does the compiler don't complain about the differences?


Anyone can explain this?

Regards,
Wouter Devos


Back to top
Gert Kello
Guest





PostPosted: Thu Nov 20, 2003 10:29 am    Post subject: Re: Syntax question Reply with quote



Quote:
It looks like there is no need to specify the arguments here in the
implementation section.
Why does the compiler don't complain about the differences?

AFAIK, it is the allowed pascal language syntax: the
procedure/function/method declaration in implementation may omit the
paramteres declaration. If it is present, it must be exactly same as in
interface part.

from Delphi help, "implementation section", the end of the first paragraph:
"You can omit parameter lists from public procedure and function
headings when you define them in the implementation section; but if you
include a parameter list, it must match the declaration in the interface
section exactly."

--
Gert


Back to top
Jim Cooper
Guest





PostPosted: Thu Nov 20, 2003 11:09 am    Post subject: Re: Syntax question Reply with quote




Quote:
AFAIK, it is the allowed pascal language syntax: the
procedure/function/method declaration in implementation may omit the
paramteres declaration. If it is present, it must be exactly same as in
interface part.

And you need to declare the parameters on overloaded methods too, if
that is the only difference in their signatures.


Cheers,
Jim Cooper

____________________________________________

Jim Cooper [email]jcooper (AT) tabdee (DOT) ltd.uk[/email]
Tabdee Ltd http://www.tabdee.ltd.uk

TurboSync - Connecting Delphi with your Palm
____________________________________________

Back to top
Andrew Denton
Guest





PostPosted: Thu Nov 20, 2003 11:26 am    Post subject: Re: Syntax question Reply with quote

Gert Kello wrote:

Quote:
It looks like there is no need to specify the arguments here in the
implementation section.
Why does the compiler don't complain about the differences?

AFAIK, it is the allowed pascal language syntax: the
procedure/function/method declaration in implementation may omit the
paramteres declaration. If it is present, it must be exactly same as
in interface part.

from Delphi help, "implementation section", the end of the first
paragraph: "You can omit parameter lists from public procedure and
function headings when you define them in the implementation section;
but if you include a parameter list, it must match the declaration in
the interface section exactly."

That is correct. All the Pascal implementations I have ever worked with
(Macinstosh, USCD P-System, Turbo 3.0 onwards) have allowed you to
exclude the parameterlist of a function/procedure. I always included
them though as you end up having to page up/down between implementation
and interface sections (this was before the days of CTRL+Up/Down Arrow).

--
Cheers,

Andy
"I want to move to Theory....Everything works in Theory"

Back to top
Wouter Devos [XLent Solut
Guest





PostPosted: Thu Nov 20, 2003 1:44 pm    Post subject: Re: Syntax question Reply with quote

Thanks all,

I was not aware of this 'feature'.
They never told me about it, and I'm definitely not going to use it. I
found it very confusing and hard to read.
But now I know it is correct.

Regards,
Wouter Devos

"Andrew Denton" <adenton.diespamdie (AT) q-range (DOT) com> schreef in bericht
news:3fbcb2f2 (AT) newsgroups (DOT) borland.com...
Quote:
Gert Kello wrote:

It looks like there is no need to specify the arguments here in the
implementation section.
Why does the compiler don't complain about the differences?

AFAIK, it is the allowed pascal language syntax: the
procedure/function/method declaration in implementation may omit the
paramteres declaration. If it is present, it must be exactly same as
in interface part.

from Delphi help, "implementation section", the end of the first
paragraph: "You can omit parameter lists from public procedure and
function headings when you define them in the implementation section;
but if you include a parameter list, it must match the declaration in
the interface section exactly."

That is correct. All the Pascal implementations I have ever worked with
(Macinstosh, USCD P-System, Turbo 3.0 onwards) have allowed you to
exclude the parameterlist of a function/procedure. I always included
them though as you end up having to page up/down between implementation
and interface sections (this was before the days of CTRL+Up/Down Arrow).

--
Cheers,

Andy
"I want to move to Theory....Everything works in Theory"



Back to top
Marc Rohloff
Guest





PostPosted: Thu Nov 20, 2003 2:29 pm    Post subject: Re: Syntax question Reply with quote

On Thu, 20 Nov 2003 11:09:03 +0000, Jim Cooper<jcooper (AT) tabdee (DOT) ltd.uk>
said ...
Quote:
And you need to declare the parameters on overloaded methods too, if
that is the only difference in their signatures.

How else can overloaded methods be different apart from their parameters?

Marc



Back to top
Jim Cooper
Guest





PostPosted: Thu Nov 20, 2003 10:03 pm    Post subject: Re: Syntax question Reply with quote


Quote:
How else can overloaded methods be different apart from their parameters?

Return types.

Cheers,
Jim Cooper

____________________________________________

Jim Cooper [email]jcooper (AT) tabdee (DOT) ltd.uk[/email]
Tabdee Ltd http://www.tabdee.ltd.uk

TurboSync - Connecting Delphi with your Palm
____________________________________________

Back to top
Marc Rohloff
Guest





PostPosted: Thu Nov 20, 2003 10:18 pm    Post subject: Re: Syntax question Reply with quote

In article <3FBD3A42.1ECFE543 (AT) tabdee (DOT) ltd.uk>, [email]jcooper (AT) tabdee (DOT) ltd.uk[/email]
says...
Quote:

How else can overloaded methods be different apart from their parameters?

Return types.
Functions must differ by more than just their return types. The

following gives a compile error:
function func(a,b:integer):integer; overload;
function func(a,b:integer):double; overload;

Marc

Back to top
Jim Cooper
Guest





PostPosted: Fri Nov 21, 2003 12:55 am    Post subject: Re: Syntax question Reply with quote


Quote:
Functions must differ by more than just their return types.

You are correct. I had thought different return types was sufficient,
but they have to be different parameter signatures as well.

Cheers,
Jim Cooper

____________________________________________

Jim Cooper [email]jcooper (AT) tabdee (DOT) ltd.uk[/email]
Tabdee Ltd http://www.tabdee.ltd.uk

TurboSync - Connecting Delphi with your Palm
____________________________________________

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.