Delphi's Type-Bondage

[prev] [thread] [next] [lurker] [Date index for 2005/08/12]

From: Phil!Gregory
Subject: Delphi's Type-Bondage
Date: 17:37 on 12 Aug 2005
Hey, here's an idea.  Let's make a language that forces the program to
adhere to extremely rigid variable typing rules.  That way, we can force
the programmer to never shoot himself in the foot.  Oh, but the whole
bondage and discipline approach to typing won't make him hate us enough.
Let's also introduce just enough type interchangeability to break anything
where he might try to use the type strictness to his benefit.

Well, it works.  I hate them.

I have to read a series of database fields into a series of variables.
Except for the types of the variables, the process is the same for all of
the fields.  I'd love to have just one function to call on all of them; it
would make things very simple.  Delphi thinks differently.  There's no way
to to hand a function a variable of an arbitrary type and have it do the
right thing; the compiler won't allow it.  The best I can do is to keep
track of the data types myself and pass an extra value into the function
to tell it what the type of the destination variable is.

"But wait!" you cry (maybe).  "You can use overloaded functions and
inheritance and stuff!"  Or, at least, that's what I though to myself.
But, while Delphi is ever-so-strict about keeping different types
separate[0], if one type is defined in terms of another (TDateTime is
really a Double, for instance), overloaded functions _cannot tell the
difference between them_.

Go, Delphi, giving me the worst of all possible worlds.


[0] To the point where this is illegal code:

    var
      arr1 : array[1..10] of Integer;
      arr2 : array[1..10] of Integer;
    begin
      arr1 := arr2

    because the compiler considers arr1 and arr2 to be of different
    types.

-- 
...computer contrarian of the first order... / http://aperiodic.net/phil/
PGP: 026A27F2  print: D200 5BDB FC4B B24A 9248  9F7A 4322 2D22 026A 27F2
--- --
M is for more, from which less was begot, and
N is for nice, which it really is not.
O is for od, which prints out things nice, while
P is for passwd, which reads in strings twice.
---- --- --

Generated at 19:00 on 15 Sep 2005 by mariachi 0.52