[fpc-pascal] Record operator for assignment
Sven Barth
pascaldragon at googlemail.com
Fri Apr 28 10:42:01 CEST 2017
Am 28.04.2017 09:23 schrieb "Ryan Joseph" <ryan at thealchemistguild.com>:
>
>
> > On Apr 28, 2017, at 1:06 PM, Sven Barth via fpc-pascal <
fpc-pascal at lists.freepascal.org> wrote:
> >
> > No, I mean
> >
> > rec := (x + y) * 2;
> >
> > The compiler has to differentiate these two.
>
> I see. It’s the parenthesis that are problematic. I guess the solution
would be curly brackets:
>
> rec := {x: 1; y: 2; z: 1}
Curly brackets are comments!
> or some magic function like writeln:
>
> rec := TMyRec(x: 1; y: 2; z: 1)
That could be a possibility as the compiler could then correctly handle the
field names, however it would have an ambiguity with typecasts until the
colon.
Though that would be solvable...
> rec := @(x: 1; y: 2; z: 1)
@ would be nonsense as that would denote a pointer.
> etc…
>
> Anyway it could be achieved that would be nice to have a built in
constructor for records on the language level.
>
Well, feel free to develop a patch, maybe it'll be accepted. I have other
fish to fry in the meantime.
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170428/d4caae09/attachment.html>
More information about the fpc-pascal
mailing list