Delphi Type Narrowing
From: Ed (contacted2001_at_yahoo.co.uk)
Date: 08/31/04
- Previous message: Duncan Murdoch: "Re: Clean up after you!"
- Next in thread: L D Blake: "Re: Delphi Type Narrowing"
- Reply:(deleted message) L D Blake: "Re: Delphi Type Narrowing"
- Reply: Maarten Wiltink: "Re: Delphi Type Narrowing"
- Reply: Jamie: "Re: Delphi Type Narrowing"
- Reply: Bruce Roberts: "Re: Delphi Type Narrowing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 31 Aug 2004 05:29:37 -0700
Hi all,
After wrestling with a bug on and off for over a week, I finally
discovered that the programmer before me had mistakenly used the
following:
var
TheData: TMemoryStream;
DataOffset: Integer;
.
.
TheData.Seek(soFromBeginning,DataOffset);
when the seek signature is:
function Seek(Offset: Longint; Origin: Word): Longint; override;
Easy enough mistake to transpose the two parameters - much harder to
spot that it had happend :-\ though. What I find rather disconcerting
is that passing an integer as a parameter to a method that requires a
word doesn't produce any compiler warnings or hints, much less a
compile time error. IIRC in java any such type narrowing would
require an explicit cast to allow compilation.
Is this a missing feature in Delphi? Can anyone suggest a reason why
this can happen e.g are there benefits from being able to do this or
technical reasons why it must be so? I'm too tired and frustrated to
think clearly about this and would greatly appreciate it if someone
with more insight than myself could clarify this stuff.
Off to the coffee machine now....
TIA,
Ed
- Previous message: Duncan Murdoch: "Re: Clean up after you!"
- Next in thread: L D Blake: "Re: Delphi Type Narrowing"
- Reply:(deleted message) L D Blake: "Re: Delphi Type Narrowing"
- Reply: Maarten Wiltink: "Re: Delphi Type Narrowing"
- Reply: Jamie: "Re: Delphi Type Narrowing"
- Reply: Bruce Roberts: "Re: Delphi Type Narrowing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|