[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 22:44:13 CEST 2019


On Fri, Jun 7, 2019 at 3:44 PM Sven Barth via fpc-devel <
fpc-devel at lists.freepascal.org> wrote:

> No, I think you *missed* the point. "^Type" defines a new type. "0..5"
> defines a new type. "set of (Alpha, Beta, Gamma)" defines a new type.
> "record a, b: longint end" defines a new types. All four of these can be
> used either to declare a named type or for an anonymous type in a variable
> declaration. However none of these can be used in a parameter declaration.
> Parameter declarations and variable declarations are different beasts, they
> have different rules (for example you can't declare open arrays outside of
> parameter declarations and no, dynamic arrays don't count, cause despite
> them sharing a syntax dynamic arrays and open arrays are different concepts)
>

You're just describing what is *currently* valid and not-valid syntax,
which we all already know. No one has explained *why* exactly "^Type" would
be somehow a negative thing in the context of method signatures, while at
the same time being perfectly fine for things like both global and local
variables, as well as constants. The following works, for example:

const X: LongInt = 12;
const Y: ^LongInt = @X;

I get what you mean about the range, set, and record declarations, however,
I don't think it's the same issue in a practical sense. All of those
*really* declare types that are *actually* new in a completely arbitrary
way. "^Type" declares a new type in the sense of "it has its own RTTI
name", but it's still ultimately just an alias that can never mean anything
other than "a pointer to a specific type that already exists."

As far as your example, I'm well aware of that kind of thing, but it's a
workaround, not a solution.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190607/c0cc8c2d/attachment.html>


More information about the fpc-devel mailing list