Assigned() generates identical code to <> nil, and not Assigned() generates
identical code to = nil.
So take your pick.

Myself - I prefer to use Assigned() - treat it as an inlined compiler
function - same applies to Pred(), Succ(), Inc() and Dec().

What really gets to me with Succ() and Pred() (Sometimes!) is that for
enumeration types they do not wrap around - because they generate identical
code to Inc() and Dec()!!!!!

Myles.


-----Original Message-----
From: Neven MacEwan [mailto:[EMAIL PROTECTED]]
Sent: Friday, 2 November 2001 3:05 p.m.
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Best practice - To except or not


Paul

Thanks for the help, It would be great it assigned() worked wouldn't it
Maybe there is a suggestion for borland in there

This leads to another question, is 'assigned()' pref to '<> nil'?, is
pred(count) better thasn Count-1?

Actually thats inc(1) questions, or was that 1+1 questions

It must be friday

Neven


----- Original Message -----
From: "Paul Heinz" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Friday, November 02, 2001 2:53 PM
Subject: RE: [DUG]: Best practice - To except or not


> Sandeep wrote:
>
> > > > This is better
> > > >
> > > >   if Assigned (Datasource.DataSet.Connection)
> > > >   then Result := Datasource.DataSet.Connection;
> > >
> > >
> > > if Datasource.Dataset is nil won't this raise
> > > an exception?
> >
> > Conditon evaluates to false in that case
>
> In Delphi 5, you get an access violation since Assigned only tests the
final
> deref not the early one. Maybe it's changed in Delphi 6.
>
> TTFN,
>   Paul.
>
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to