Hi *,

seems, that overloading of Inc, Dec internal compiler procedures is not allowed. Is it by intention or can it be fixed (adding overload keyword to system function definitions?).

I would like to add support for:

  procedure Inc(var a: integer; b: single); overload; inline;
  begin
    a := a + Round(b);
  end;
  procedure Inc(var a: single; b: single); overload; inline;
  begin
    a := a + b;
  end;
  procedure Dec(var a: integer; b: single); overload; inline;
  begin
    a := a - Round(b);
  end;
  procedure Dec(var a: single; b: single); overload; inline;
  begin
    a := a - b;
  end;

But nor this approach nor operator overloading is allowed.
(Error message: Wrong number of parameters specified for call to "Inc" is emited , when simple Inc(a); is used I can avoid this error by prefixing System.Inc(), but it will require change on many places in code)

I need use addition or subtraction on operands, which left of them can be either "integer" or "single" type (specialized generic type)

Example:

var x,y: TAnyNumericType; x1,y1: single; i: integer;
Inc(x, x1); // x,y can be either integer or single
Inc(y, y1);
Inc(i); // Error: Wrong number of parameters specified for call to "Inc"

TIA

-Laco.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to