Page 1 of 1

Incompatible assignment

Posted: Tue Mar 14, 2017 1:42 pm
by Ivan Denisov
I forgot, did we discuss this issue?

Re: Incompatible assignment

Posted: Tue Mar 14, 2017 8:58 pm
by DGDanforth
Ivan Denisov wrote:I forgot, did we discuss this issue?
I think we did but I find that behavior very annoying. Why should one be
forced to add the "syntactic sugar" of

Code: Select all

TYPE 
     X = ARRAY 3 OF REAL;
VAR
     a: X;
     b: X;
when the semantics is the same in both cases.

Re: Incompatible assignment

Posted: Tue Mar 14, 2017 9:37 pm
by cfbsoftware
DGDanforth wrote:Why should one be
forced to add the "syntactic sugar"
You are not forced to do that. It is perfectly adequate to declare both variables in the same list:

Code: Select all

MODULE Anonymous;

VAR
  a: ARRAY 3 OF REAL;
  b: ARRAY 3 OF REAL;
  c, d: ARRAY 3 OF REAL;

BEGIN
  c := d; (* OK *)
  a := b
END Anonymous.
Refer to Appendix A: Definition of Terms of the Component Pascal Language Report to see why this is so.

Re: Incompatible assignment

Posted: Tue Mar 14, 2017 9:46 pm
by DGDanforth
Chris,
Good point. I'll remember that.