[fpc-devel] Thoughts on being able to declare "pointer-to-type" parameters directly in method signatures?
Jonas Maebe
jonas at freepascal.org
Fri Jun 7 20:35:33 CEST 2019
On 07/06/2019 20:26, Ben Grasset wrote:
> On Fri, Jun 7, 2019 at 1:47 PM Jonas Maebe <jonas at freepascal.org
> <mailto:jonas at freepascal.org>> wrote:
>
> It would be inconsistent to only allow such declaration for pointers,
> and not for other types (a programming language should strive to be as
> orthogonal as possible, with as few exceptions as possible).
>
>
> I can't think of any particular variety of normal declaration *other*
> than pointer aliases that aren't allowed in parameter lists, though.
You mention them later:
> Apart from that, what else is there? Parameters can be records, classes,
> objects, interfaces, function types, primitives, e.t.c.
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;".
> As you said, "array of type" is fine (in all modes, I think.) In fact, > that's one of the reasons that the inability to use the "^" symbol in
> front of a type for a pointer alias has always seemed like "missing"
> functionality to me, as the fact that arrays can work like that makes me
> think it's not unrealistic to implement the same kind of thing for pointers.
An open array has specific semantics that are completely different from
any regular array type. Your "^Type" inline type definition would behave
exactly the same as a regular pointer type definition.
Jonas
More information about the fpc-devel
mailing list