>C, I remember having operator overloaded functions for
>= well == in C. Does D4 support this? I know it supports
>default parameters which is really cool. It seems to me
>that D4 is very close to the C language these days, but
>is still a bit behind (about 5 years).
>It was really nice for structures as you could do
>if (record1 == Record2)

(You're actually referring to C++ a slightly different beast than
C).  It's not really an issue of who's behind but rather a design
decision and the Delphi team decided that they would not implement
operator overloading in the extended pascal syntax.  Originally
they also ruled out overloading of functions but this was the influence
of certain team members and changes in the team have resulted in
overloading being implemented.  There are areas of the Delphi
syntax which surpass C++ such as the property syntax allowing
expression assignment to have an event attached whereas in
C++ and java (java doesn't do op overloading either) both require
SetProperty(Value) to be used by the enduser.  Delphis properties
enable the user to not need to know the inner implementation
of the class only that it is a property as opposed to C++ where the
end user see Fields and methods not really encapsulated properties.

>and one I really miss from c is:

>Say name is a string
>Captionm := (Name  > '') ? 'Hello'+Name : 'You should enter a name'
>it is like an IF THEN ELSE in a line. first the comparason, then the ?
means if TRUE and the : means ELSE
>So you could save a lot of typing if you wanted say 4 or 5 checks in one
line of code.

First the bad news Delphi doesn't support this operator and most likely
never will.

Actually it's better than an IF THEN ELSE since it performs substitution
which can be a statement, variable or constant.  So this would have been

if Name<>'' then Captionm := 'Hello '+Name
else 'You should enter a name';

this would be even more obvious in something like

Showmessage('There '+((Count==1)?'is ':'are ')+IntToStr(Count)+'
item'+((Count==1)?' ':'s ')+'selected.');

producing either (assuming I didn't bollocks the code)
There is 1 item selected.
or
There are 4 items selected.

without needing an if statement and 2 complete showmessage statements. Note
that this is a simple
case because you could have a number of other twists... There are algorithms
in B-tree implementation
where you need to select one of two different pointer to pointers to pass
down a recursive add.   The
code in pseudo or pascal looks ugly next to Cs Tertiary operator.  Now if
there was a switch that could
perform substitution... ;)

there are a number of things I'd like to see in Delphi such as template
implementation and stronger
syntax support for Delphi set notations.  Stronger enumeration definition
would also be nice.

--
Aaron@home

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to