[fpc-pascal] Re: Changing variable in conditional
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Thu Jan 10 12:43:50 CET 2013
leledumbo wrote:
>> If Pascal /had/ to have some sort of multiple assignment, I'd have
> thought borrowing an idea from Perl and doing something like
>
> [a, b, c] := (d = e);
>
> would have been minimally acceptable.
>
> I would pick from Lua instead, it looks cleaner. Well... I'll make it
> stricter though, by making the number of elements on both side must equal.
> e.g.:
>
> a,b,c := v1,v2,v3;
> a,b := b,a; // value swapping
I admit that I was- in large part- borrowing from APL. In other words,
if the number of elements on both sides of the expression is the same
you get a one-to-one correspondence but if the RHS only has a single
element it's expanded. APL will also do things comparable with treating
[a, b, c, a] := [1, 2];
as though it really was
[a, b, c, a] := [1, 2, 1, 2];
but that's getting well outside what's reasonable particularly since APL
makes a point of not defining the order of internal operations (i.e. the
final value of a is, at best, implementation-defined).
However as I said: it's not Pascal :-)
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal
mailing list