Board index » delphi » dereferencing record types

dereferencing record types

I'm changing all my code from Turbo Pascal to Delphi 5.
In Turbo Pascal a pointer to a record must be derefenced using :
MyRec^.field,
By accident I discovered that in Delphi 5 I can use :
MyRec.Field, without the symbol ^ .
Question :
It's safe to use this approach?, now the ^  it's optional?

Thanks,
Donis.

 

Re:dereferencing record types


Donis,

It's a personal preference, I think.

What I do is to stick to the Borland conventions for new stuff - e.g. a
TForm is really a pointer but I don't use Form^.Close, whereas for my own
stuff (perhaps stuff I've had since TP like yourself), if I've defined
something as a pointer, I use it as such.  In your example, I would not drop
the "^" part.

In fact, I believe many of the common beginner's problems can arise becuase
the use of pointers is not made clear - e.g. having to use Assign to
transfer values because Orange := Apple only makes pointers equal.

Just my opinion.....

David

Quote
"Donis" <do...@zsl.com.br> wrote in message news:3a49ecf8_1@dnews...
> I'm changing all my code from Turbo Pascal to Delphi 5.
> In Turbo Pascal a pointer to a record must be derefenced using :
> MyRec^.field,
> By accident I discovered that in Delphi 5 I can use :
> MyRec.Field, without the symbol ^ .
> Question :
> It's safe to use this approach?, now the ^  it's optional?

> Thanks,
> Donis.

Re:dereferencing record types


Quote
On Wed, 27 Dec 2000 11:26:48 -0200, "Donis" <do...@zsl.com.br> wrote:
> It's safe to use this approach?, now the ^  it's optional?

Yes it is safe to use this approach, and yes Object Pascal
dereferences automatically where unambiguous.
--
Rick Rogers (TeamB); Fenestra Technologies, http://www.fenestra.com/
  Use Borland servers; posts via others are not seen by TeamB.
  For more info, see http://www.borland.com/newsgroups/genl_faqs.html

Other Threads