function results in `with' statements

Adriaan van Os gpc at microbizz.nl
Fri Oct 22 21:07:24 CEST 2004


Frank Heckenbach wrote:

> Currently GPC allows function results in `with' statements, as in:
>
> program foo;
>
> type
>   a = record
>     b, c: Integer
>   end;
>
> function f: a;
> begin
>   f := a[b: 2; c: 3]
> end;

MetroWerks CodeWarrior Pascal doesn't know this construction.

>
> begin
>   with f do WriteLn (b, c);
> end.

Allowed in MW Pascal.

> However, GPC currently also allows assignments to the components,
> such as:
>
>   with f do b := 2
>
> which is quite clearly wrong.

Allowed also (and wrong also).

> Probably for this reasone, EP forbids function results in `with'
> statements at all (6.9.3.10: with­element = variable­access |
> constant­access.). I don't know about other dialects (BP has no
> records as result types, so the issue doesn't arise. What about
> Delphi etc.?).
>
> At the moment, I'd tend to follow EP here and forbid them at all. Or
> does anyone think it's really necessary to have them? (Which would
> probably imply more work to make the fields read-only.)

Not a big issue for me.

Regards,

Adriaan van Os




More information about the Gpc mailing list