On Nov 13, 2007, at 12:03 PM, Sam Liddicott wrote:
* Damien Gerard wrote, On 13/11/07 10:43:
I don't think nobody is complaining here since everybody is free to
use it or not.
Oh some people complain about the widget encapsulation ??? So they
don't use QT as well and if they want a multiplatform software what
do
they use ? Java ? :)
And as it was said before, why using variants when standard types are
enough ? Just to see in your code S := N instead of S :=
IntToStr(N); ?
For your example, you are converting the way that does not require
variants, so of course it shows that variants are not required. Please
excuse this example being in mostly-C;
int s;
if (data.t == D_INT) {
s=data.t_int.value;
} else if (data.t == D_LONGINT) {
if (data.t_longint.value > MAXINT) error();
s=data.t_longint.value);
} else if (data.t == D_STR) {
errno=0;
s=strtol(data.t_str.value, NULL. 10);
if (errno!=0) error();
} else {
error();
}
Remind me to kill every one in my team who write this kind of code...
(I already spotted some mistakes, imagine maintaining all that
rubbish)
At least in C you can come up with a load of helper macros.
And did you try and use COM in the delphi 1 days? It was utterly mad.
People made it work and THEN gave up.
I use Delphi from its first Version under Win3.1. And of course I have
already used COM Objects.
That was one of the reason I don't like the windows platform.
About COM Objects, I agree, you want variants
Variants let the programmer concentrate on the meaning of the code
when
integrating with other systems. Often the overhead of what was being
controlled was nothing to the overhead of the variant (and of course,
this was being managed by hand in Delphi 1 anyway). And the overhead
of
writing code with variants was much less than writing code that did it
all by hand.
People keep re-inventing COM and variants all over the shop because
they
don't have com and variants when the need them.
Variants are good things but they were not created to allow lazy
programming or implicit convertions. They were made in order to
provide a dynamic type when you can't know the type of the variable
(in SQL queries for example).
Maybe that's why there were made, but they were put into Delphi to
allow implicit conversions from unspecified types from systems that
use
unspecified types, and to let Delphi use easily integrate with systems
that use unspecified types.
There's nothing wrong with an implicit conversion if the generated
code
is pretty much exactly what you would (should) have explicitly
written.
anyway... I think we fully explored other peoples opinions. I think
you
don't like variants because they ways in which I (also) think other
people shouldn't use them are bad.
:)
They are not bad. They have to be used for what they have been created
for :p
Sam
--
Damien Gerard
[EMAIL PROTECTED]
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives