[fpc-pascal] Record operator for assignment

Ryan Joseph ryan at thealchemistguild.com
Fri Apr 28 08:01:22 CEST 2017

> On Apr 28, 2017, at 12:43 PM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> It would introduce an ambiguity as "(x" could also complete to other expressions (e.g. "(x + y) * 2" or even merely "(x)"). Especially older Pascal compilers were geared towards the simplicity of the language and thus they didn't add it. For FPC it simply never came up.

I never thought about it either until I saw some c++ code doing it. Despite having overlooked it, it’s basically a built in record constructor that’s been in the language since forever. First it was making functions that paired with records and now it’s constructors and "advanced record syntax" when the more obvious and simpler solution was there all along. Maybe I’m crazy though. ;)

You mean like: 

rec := (x: (x + y) * 2; y: 0; z: 0);

Why can’t everything between : and ; just be treated like a normal assignment? “x” is already defined but it’s just a label and not part of the assignment.

> The compiler currently prefers to cast array constructors towards sets, especially if they contain values that could be expressed as a set. That will change once proper support for array constructors is added. Though I don't know whether this would work then ;)

Huh, that syntax works in constructors, just not in the operator overloading. Anyways I guess I’ll just assume that’s not implemented behavior.


	Ryan Joseph

More information about the fpc-pascal mailing list