Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Compiler Bug?
Mon, Apr 13 2015 8:17 PMPermanent Link

Doug B

I couldn't figure out why my request class was giving me exceptions when I accessed it, until I found this line:

 fServerRequest := TServerRequest.Create;

When I changed it to:

 fServerRequest := TServerRequest.Create(nil);

Everything worked.

Shouldn't the compiler complain that I was missing a parameter?

Thanks,
Doug
Tue, Apr 14 2015 2:32 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Doug,

<< Shouldn't the compiler complain that I was missing a parameter? >>

TObject.Create

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Apr 15 2015 4:02 AMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

> << Shouldn't the compiler complain that I was missing a parameter? >>
>
> TObject.Create

Forgive me, but I don't understand that. I checked the help to see if
that was a pointer to something, but nothing obvious.

--

Matthew Jones
Wed, Apr 15 2015 12:27 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Forgive me, but I don't understand that. I checked the help to see if
that was a pointer to something, but nothing obvious. >>

He was calling the TObject.Create method, not the TComponent.Create method.
One must always remember that there's a public TObject.Create ancestor
method that will match a Create call without any parameters.  When that
happens, the TComponent.Create method isn't called, and all of the
ownership, parenting, etc. initialization that occurs normally will *not*
occur.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Apr 15 2015 12:54 PMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

> << Forgive me, but I don't understand that. I checked the help to see
> if that was a pointer to something, but nothing obvious. >>
>
> He was calling the TObject.Create method, not the TComponent.Create
> method. One must always remember that there's a public TObject.Create
> ancestor method that will match a Create call without any parameters.
> When that happens, the TComponent.Create method isn't called, and all
> of the ownership, parenting, etc. initialization that occurs normally
> will not occur.

Ah, right. A sort of standard inheritance gotcha, that we don't usually
fall over, but just might.

--

Matthew Jones
Thu, Apr 16 2015 3:37 PMPermanent Link

Doug B

Thanks, Tim.

I guess it's just different in Delphi, where the following would show an error:

" E2035 Not enough actual parameters"

var
 c: TComponent;
begin
 c := TComponent.Create;
end;

Doug

"Tim Young [Elevate Software]" wrote:

Matthew,

<< Forgive me, but I don't understand that. I checked the help to see if
that was a pointer to something, but nothing obvious. >>

He was calling the TObject.Create method, not the TComponent.Create method.
One must always remember that there's a public TObject.Create ancestor
method that will match a Create call without any parameters.  When that
happens, the TComponent.Create method isn't called, and all of the
ownership, parenting, etc. initialization that occurs normally will *not*
occur.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Apr 20 2015 4:29 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Doug,

<< I guess it's just different in Delphi, where the following would show an
error: >>

EWB's compiler has automatic overloads.  If it finds a method with the
correct signature *anywhere* in a given class hierarchy, then it will
consider it resolved and use it.

Tim Young
Elevate Software
www.elevatesoft.com


Image