On Fri, Jun 7, 2019 at 2:35 PM Jonas Maebe <jo...@freepascal.org> wrote:

> None of these can be defined as a type in parameter lists. Keep in mind
> that "^Type" defines a new type. Semantically, it's at the same level as
> "0..5" and "record a, b: longint end;".
>

Right, that's the point. There's nothing else that *would* make any
syntactic sense in a parameter list besides "^Type" that isn't already
allowed in them.

On Fri, Jun 7, 2019 at 2:35 PM Jonas Maebe <jo...@freepascal.org> wrote:

> Your "^Type" inline type definition would behave  exactly the same as a
> regular pointer type definition.
>

 Of course. It would be strange if it didn't, I think. That's the whole
point.

Here's another more simplistic example, in {$mode ObjFPC} this time:

program Example;

{$mode ObjFPC}

generic procedure GenProc<T>(Param: ^T); // <-- does not compile
var
  P: ^T; // <-- compiles just fine
begin
end;

procedure NonGenProc(Param: ^LongInt); // <-- does not compile
var
  P: ^LongInt; // <-- compiles just fine
begin
end;

begin
end.

To me it's always seemed illogical (in various different Pascal compilers
over time, not just FPC) that the "parameter" declarations there don't
work, whereas things like the "var" ones (which are just as "inline", I'd
say) work just fine.

It comes across as the kind of thing that would happen if someone simply
forgot to account for the "^" symbol in their code for parsing method
signatures, not like any kind of intentional design choice.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to