 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Martin James Guest
|
Posted: Wed Aug 27, 2003 11:36 pm Post subject: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
1. Long strings can be typecast to Tthreads, Tcomponents or indeed, any
other object, without any warning, despite the fact that strings, as a
whole, are implicitly a variable-length data element & should not be
castable to anything except another variable-length element, eg. another
string/buffer type, (ducking from Rudy now..)
2. The compiler steadfastly refuses to count the items in my const arrays,
forcing me to do it myself. Luckily, compilation is so fast that it's
easier to underGuess & then keep incrementing/compiling until the error
stops.
3. TThread is missing...well.. a lot, and has some excess baggage that
smells really bad. Dumping 'synchronize', (and now the apalling-looking
'checkSynchronize' that seems to work by CPU polling), & adding a
producer-consumer mailbox would be a start. Those examples that use
'waitFor' loops in an event hander to wait for thread results could also be
advantageously dropped before any more bad/inefficient code is written.
4. No warning for 'myObject.create' instead of
'myObject:=TmyObject.create'. 99% of all household AV-on-starts are due to
this error.
5. No contiguous-in-memory string container.
6. ..... raise ErantSpaceOverflow
Rgds,
Martin
|
|
| Back to top |
|
 |
Lauchlan M Guest
|
Posted: Wed Aug 27, 2003 11:36 pm Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
| Quote: | 4. No warning for 'myObject.create' instead of
'myObject:=TmyObject.create'. 99% of all household AV-on-starts are due
to
this error.
|
It would be nice if they could add a warning for that. I've been caught by
this too.
Lauchlan M
|
|
| Back to top |
|
 |
Ignacio Vazquez Guest
|
Posted: Wed Aug 27, 2003 11:41 pm Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
"Martin James" <mjames_falcon (AT) dial (DOT) pipex.com> wrote in message
3f4d4053$2 (AT) newsgroups (DOT) borland.com...
| Quote: | 2. The compiler steadfastly refuses to count the items in my const
arrays, forcing me to do it myself. Luckily, compilation is so fast that
it's easier to underGuess & then keep incrementing/compiling until the
error stops.
|
QC#4839 (vote early vote often)
| Quote: | 6. ..... raise ErantSpaceOverflow
|
Heh.
Cheers,
Ignacio
--
No, don't send me e-mail directly. No, just don't.
|
|
| Back to top |
|
 |
Robert Love Guest
|
Posted: Thu Aug 28, 2003 12:30 am Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
| Quote: | 4. No warning for 'myObject.create' instead of
'myObject:=TmyObject.create'. 99% of all household AV-on-starts are due
to
this error.
It would be nice if they could add a warning for that. I've been caught by
this too.
|
Add it to qc.borland.com :-)
Robert Love
|
|
| Back to top |
|
 |
Lauchlan M Guest
|
Posted: Thu Aug 28, 2003 1:29 am Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
| Quote: | 4. No warning for 'myObject.create' instead of
'myObject:=TmyObject.create'. 99% of all household AV-on-starts are
due
to
this error.
It would be nice if they could add a warning for that. I've been caught
by
this too.
Add it to qc.borland.com
|
I've never got this to work. Apparently it will be part of D8, so I guess
I'll try it again then.
Lauchlan M
|
|
| Back to top |
|
 |
Will DeWitt Jr. Guest
|
Posted: Thu Aug 28, 2003 8:26 am Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
Ignacio Vazquez wrote:
| Quote: | 2. The compiler steadfastly refuses to count the items in my const
arrays, forcing me to do it myself. Luckily, compilation is so
fast that it's easier to underGuess & then keep
incrementing/compiling until the error stops.
QC#4839 (vote early vote often)
|
I think he's referring to the following situation--
const
DataArray: array[0..100] of word = (
$0000, $0000, $0000, $0000,
$0000, $0000, $0000, $0000,
// ...
$0000, $0000, $0000, $0000);
----
Where there is a mismatch as to the number of elements specified, and
you need to add or remove elements until you match the declaration you
made (simpler for small arrays, but hideously difficult for larger
arrays. An ideal solution would be to tell you how many elements you
defined vs. how many were allocated via the array declaration (so you
can see the difference and adjust exactly to what is needed, or, if
you're importing data from another language, see how many elements need
to be defined in the array to make the compiler error stop).
Of course I might be wrong too, and he might be talking about 'array of
const' parameters to functions (the Delphi way of having variable
argument / parameters for procedures / functions). =)
Will
|
|
| Back to top |
|
 |
Will DeWitt Jr. Guest
|
Posted: Thu Aug 28, 2003 1:01 pm Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
Look up QC 5762. If you have any ideas on how I can shorten the short
subject description, or how I can improve the description in general,
let me know. =)
Will
|
|
| Back to top |
|
 |
Dave Nottage (TeamB) Guest
|
Posted: Thu Aug 28, 2003 1:04 pm Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
Will DeWitt Jr. wrote:
| Quote: | Look up QC 5762. If you have any ideas on how I can shorten the short
subject description, or how I can improve the description in general,
let me know. =)
|
Looks fine to me <g>
--
Dave Nottage (TeamB)
|
|
| Back to top |
|
 |
Ignacio Vazquez Guest
|
Posted: Thu Aug 28, 2003 1:07 pm Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
"Will DeWitt Jr." <edge (AT) boink (DOT) net> wrote in message
[email]3f4dbcba (AT) newsgroups (DOT) borland.com[/email]...
| Quote: | An ideal solution would be to tell you how many elements you
defined vs. how many were allocated via the array declaration
|
We'll have to agree to disagree then. In my mind, the ideal solution is to
declare it as a dynamic array and have the compiler automagically convert it
to a static array.
Cheers,
Ignacio
--
No, don't send me e-mail directly. No, just don't.
|
|
| Back to top |
|
 |
John Herbster (TeamB) Guest
|
Posted: Thu Aug 28, 2003 1:18 pm Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
"Will DeWitt Jr." <edge (AT) boink (DOT) net> wrote
| Quote: | Look up QC 5762. If you have any ideas on how I can
shorten the short subject description, or how I can improve
the description in general, let me know. =)
|
I added the following comment to your QC 5762 and voted for it.
"I would like to see the compiler error message include
(1) how many elements were defined and
(2) how many were allocated via the array declaration."
|
|
| Back to top |
|
 |
Ignacio Vazquez Guest
|
Posted: Thu Aug 28, 2003 1:43 pm Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
"Will DeWitt Jr." <edge (AT) boink (DOT) net> wrote in message
3f4e01d7$1 (AT) newsgroups (DOT) borland.com...
| Quote: | (Or at least, addresses the problem correctly and leaves
the array as a dynamic array.)
|
The problem isn't that it doesn't result in a dynamic array, the problem is
that the compiler should be able to figure out how large the array should
be.
Cheers,
Ignacio
--
No, don't send me e-mail directly. No, just don't.
|
|
| Back to top |
|
 |
Will DeWitt Jr. Guest
|
Posted: Thu Aug 28, 2003 1:53 pm Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
Ignacio Vazquez wrote:
| Quote: | The problem isn't that it doesn't result in a dynamic array, the
problem is that the compiler should be able to figure out how large
the array should be.
|
Well, you used TIntegerDynArray in your declaration in the description,
and that's what lead me down the "this must be a dynamic array
initialization problem". If your issue is that you want a way to
define an array without specifying the size (and leaving it up to
Delphi to determine the size at compile time), then the only solution I
can think of is what I mentioned in the comment for your report-- have
Delphi realize that you're not providing a pointer to the initial
dynamic array, and instead that you're providing the elements for the
array and create a temporary / hidden array for you. The problem is,
for an array with a single element, Delphi would most likely be unable
to tell if you're assigning something to the pointer for the dynamic
array or if you're specifying only a single element that should be in
the temporary / hidden dynamic array it creates on your behalf. In the
latter case, you'd be breaking existing code that relied on being able
to initialize dynamic arrays to values via pointers I think.
I'm thinking you'll likely get a "won't do" tagged on your report. You
might consider looking at report 5762, which while not as elegant a
solution as what you're hoping for I think, is still better than having
to guess how big the array needs to be or how many elements you have to
define to fill the array. =)
Will
|
|
| Back to top |
|
 |
Craig Stuntz [TeamB] Guest
|
Posted: Thu Aug 28, 2003 1:56 pm Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
Martin James wrote:
| Quote: | 1. Long strings can be typecast to Tthreads, Tcomponents or indeed,
any other object, without any warning, despite the fact that strings,
as a whole, are implicitly a variable-length data element & should
not be castable to anything except another variable-length element,
eg. another string/buffer type, (ducking from Rudy now..)
|
Worse than that, you can cast anything to anything! Oh, no!
Oh, wait. That's exactly what a hard cast is *supposed* to do....
I suppose Borland could add a warning whenever you did a hard cast,
but I have a feeling that would annoy people. I don't agree that
strings are a special case -- they're an address just like an object
reference. The big gotcha with casting strings is reference counting,
but that applies to interfaces and dynamic arrays equally.
-Craig
--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : http://delphi.weblogs.com
InterBase PLANalyzer 1.1 -- Free InterBase query optimization
tool: http://delphi.weblogs.com/IBPLANalyzer
|
|
| Back to top |
|
 |
Ignacio Vazquez Guest
|
Posted: Thu Aug 28, 2003 2:02 pm Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
"Will DeWitt Jr." <edge (AT) boink (DOT) net> wrote in message
[email]3f4e0964 (AT) newsgroups (DOT) borland.com[/email]...
| Quote: | Ignacio Vazquez wrote:
The problem isn't that it doesn't result in a dynamic array, the
problem is that the compiler should be able to figure out how large
the array should be.
Well, you used TIntegerDynArray in your declaration in the description,
and that's what lead me down the "this must be a dynamic array
initialization problem".
|
Good point. Let me see if I can clean it up...
Cheers,
Ignacio
--
No, don't send me e-mail directly. No, just don't.
|
|
| Back to top |
|
 |
Ignacio Vazquez Guest
|
Posted: Thu Aug 28, 2003 2:06 pm Post subject: Re: 5 stinkiest 'features' in Delphi *anySinceD4* |
|
|
"Ignacio Vazquez" <ivazquezATorioncommunications.com> wrote in message
3f4e0b7d$1 (AT) newsgroups (DOT) borland.com...
| Quote: | "Will DeWitt Jr." <edge (AT) boink (DOT) net> wrote in message
[email]3f4e0964 (AT) newsgroups (DOT) borland.com[/email]...
Well, you used TIntegerDynArray in your declaration in the description,
and that's what lead me down the "this must be a dynamic array
initialization problem".
Good point. Let me see if I can clean it up...
|
Fixed. And I've verified that it does in fact give the same result.
Cheers,
Ignacio
--
No, don't send me e-mail directly. No, just don't.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|