On Wed, Jan 4, 2017 at 10:24 AM, Ryan Joseph <r...@thealchemistguild.com>
wrote:

> But how do you assign to “something" then if you don’t know the type? The
> param is “var” so shouldn’t I be able to assign to the param and return it
> back to the caller? In your example how could I return 5 to “i” inside
> GetSomething?
>
> Treat is as a pointer (it's an implicit pointer anyway)

function GetSomething (var something): boolean
var
  pi: PInteger;
begin
  pi:=@something;
  GetSomething:=pi^>=5;
end;

or an old-school way using "absolute".

function GetSomething (var something): boolean;
var
  i: Integer absolute something;
begin
  GetSomething:=i>=5;
end;

var
  i : integer;
begin
  i:=3;
  writeln(GetSomething(i));
end.

check out "anysort" function
http://wiki.freepascal.org/Array_sort

It's using untyped parameter to perform a sort on an arbitrary type array

thanks,
Dmitry
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to