[fpc-devel] type x = type byte // in overloaded params with/without var

Martin lazarus at mfriebe.de
Thu Aug 6 20:29:48 CEST 2009


I read up on  
http://www.hu.freepascal.org/lists/fpc-devel/2006-October/009116.html
I understand that assignment is still possible via := / due to implicit 
conversion.

Just a question in the example below, 3 pairs of overload procedures.
And 3 types: Integer, t1, t2

Only the one with "var" param rejects the Integer.

Is this the only way do reject the integer?
I understand I could do a record type (and overload +/-), but I also 
whish to use bit-logig via and/or (which I believe I can not overload?)


To make it worse(actually better): if I use "string" instead of integer, 
byte, qword => all 3 give:
project1.lpr(30,3) Error: Can't determine which overloaded function to call

Worse because it's a differnet behaviour, and hence more complicated, 
less predictable (without even more knowledge)
Better, because at least it rejects, what I want it to reject


Best Regards
Martin


program Project1;
{$mode objfpc}{$H+}
type
  t1 = type byte;
  t2 = type qword;

procedure a(x: t1);
begin end;
procedure a(x: t2);
begin end;

procedure b(var x: t1);
begin end;
procedure b(var x: t2);
begin end;

procedure c(const x: t1);
begin end;
procedure c(const x: t2);
begin end;

var
v: integer;
v1: t1;
v2: t2;

begin
  a(v);
  //b(v);
  c(v);
end.




More information about the fpc-devel mailing list