[fpc-devel] Thoughts on being able to declare "pointer-to-type" parameters directly in method signatures?
Ryan Joseph
genericptr at gmail.com
Mon Jun 10 03:05:40 CEST 2019
> On Jun 9, 2019, at 8:11 PM, Dmitry Boyarintsev <skalogryz.lists at gmail.com> wrote:
>
> Is it because parameter types are doesn't really match a type definition.
> One can't do
> function myFunc(var a: record a,b: integer; end): integer;
> the record type has to be declared separately.
> or
> declaring
> function myFunc(var a: array of integer): integer;
> is 100% not the same as
> TArrayType = array of Integer;
> function myFunc(var a: TArrayType ): integer;
>
What if static array and record types were the exception? I agree it looks bad using anonymous records in parameters but pointers makes perfect sense to me. I think simply allowing pointers (and perhaps dynamic arrays) covers 99% percent of use cases.
Personally I’ve had to write dummy types more than once in order to get around this design problem. If I had to guess I’d say this is just a historical relict the didn’t stand up to the test of time.
Regards,
Ryan Joseph
More information about the fpc-devel
mailing list