Incompatible assignment

Post Reply
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Incompatible assignment

Post by Ivan Denisov »

I forgot, did we discuss this issue?
Attachments
incass.png
incass.png (6.43 KiB) Viewed 4999 times
User avatar
DGDanforth
Posts: 1061
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, California, USA
Contact:

Re: Incompatible assignment

Post 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.
cfbsoftware
Posts: 204
Joined: Wed Sep 18, 2013 10:06 pm
Contact:

Re: Incompatible assignment

Post 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.
User avatar
DGDanforth
Posts: 1061
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, California, USA
Contact:

Re: Incompatible assignment

Post by DGDanforth »

Chris,
Good point. I'll remember that.
Post Reply