Incompatible assignment

Incompatible assignment

Postby Ivan Denisov » Tue Mar 14, 2017 1:42 pm

I forgot, did we discuss this issue?
Attachments
incass.png
incass.png (6.43 KiB) Viewed 1960 times
Ivan Denisov
 
Posts: 1694
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: Incompatible assignment

Postby DGDanforth » Tue Mar 14, 2017 8:58 pm

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

Re: Incompatible assignment

Postby cfbsoftware » Tue Mar 14, 2017 9:37 pm

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

Re: Incompatible assignment

Postby DGDanforth » Tue Mar 14, 2017 9:46 pm

Chris,
Good point. I'll remember that.
User avatar
DGDanforth
 
Posts: 1061
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, California, USA


Return to Archive

Who is online

Users browsing this forum: No registered users and 1 guest

cron