Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-08

type x = type byte // in overloaded params with/without var

2 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

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.

Reply by email

Martin
to Martin

ah it seem 2.3.1 has a bettter implementation.

It always gives
project1.lpr(30,3) Error: Can't determine which overloaded function to call

:)

Martin wrote 64 lines
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. _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email