[fpc-devel] Thoughts on being able to declare "pointer-to-type" parameters directly in method signatures?
Ben Grasset
operator97 at gmail.com
Fri Jun 7 23:17:32 CEST 2019
On Fri, Jun 7, 2019 at 3:44 PM Sven Barth via fpc-devel <
fpc-devel at lists.freepascal.org> wrote:
> "0..5" defines a new type. "set of (Alpha, Beta, Gamma)" defines a new
> type. "record a, b: longint end" defines a new types.
>
Building on my last reply, also, here's an example that shows what I see as
the actual hypothetical ramifications of those in method signatures:
program Example;
{$mode ObjFPC}
type Letter = (A, B, C);
{ this *could* be valid code, because something like "TakesASet([A, C])" is
valid code }
procedure TakesASet(ASet: set of Letter);
begin
end;
{ this *could not* be valid code, because D, E and F do not exist outside
to actually call it with }
procedure ImpossibleTakesASet(ASet: set of (D, E, F));
begin
end;
{ this *could* be valid code, because something like "TakesARange(2)" is
valid code }
procedure TakesARange(ARange: 0..3);
begin
end;
{ this would be nonsensical IMO, because you could only call it with a
variable of an existing named record type with identical fields, making
it pointless }
procedure TakesARecord(ARecord: record A, B: LongInt; end;);
begin
end;
begin
end.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190607/09a9e357/attachment.html>
More information about the fpc-devel
mailing list