"weak" strong typing...

"weak" strong typing...

I have two types defined:

TOneType = type RawByteString;
TSecodType = type RawByteString;

Is it possible to force strong typing in the method definition:

procedure PassOnlyOneType(const OneType: TOneType);

so that it is not possible to call with a parameter of another type?

var
SecondType: TSecondType;

PassOnlyOneType(SecondType); <--- here I want to have a compilation error, now error not occur

How properly construct new type?

Comments

  1. You know that you can't achieve this with a dynamic string type. So what else have you got? Record is it. And it works fine. I don't understand your objection.

    ReplyDelete
  2. David Heffernan My objection you see in new thread with record and memory leak ;-)

    ReplyDelete
  3. Jacek Laskowski Well, I gave you a perfectly good workaround. So that should be case closed. And why are you even using strings anyway. This looks like a byte array.

    ReplyDelete

Post a Comment