🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Richard Pattis Fri, 03 Oct 1986 16:07
THe type of Indexes in Open Array Parameters
#543
Author: Richard Pattis
Date: Fri, 03 Oct 1986 16:07
14 lines
1376 bytes
What is the type of the index in open array parameters?  How can you justify
your answer (quotes from Wirth)? This problem came up in the following context:
I have been using integer variables to index open array parameters; but the
PCollier compiler requires that open array parameters be accessed by using
the cardinal type.  I tried to convince myself that this was an error, but I
couldn't see anything in Wirth's book that directly supported my position.

To access declared types using integer indexes, I can write (according to the
new Modula-2 syntax) TYPE A = ARRAY INTEGER[1..10] OF T. The question could
be resolved if Wirth says that indexes must be assignment compatible (but not
compatible) with their declared (or implied) index types.

Rich
-------
Re: THe type of Indexes in Open Array Parameters
#544
Author: Charles D. Farnum
Date: Fri, 03 Oct 1986 18:13
17 lines
1482 bytes
In article <12243873849.8.PATTIS@WARD.CS.WASHINGTON.EDU> PATTIS@WARD.CS.WASHINGTON.EDU (Richard Pattis) writes:
>What is the type of the index in open array parameters?  How can you justify
>your answer (quotes from Wirth)? ...

According to the third edition of ``Programming in Modula-2'', p. 152,
section 8.1 of the Report:

    ...the designator A[E] denotes that component of A whose index is the 
    current value of the expression E.  The index type of A must be
    _assignment_compatible_ [emphasis Wirth's] with the type of E...

The index type of an open array thus becomes academic; if we assume that
it is some subrange of CARDINAL or INTEGER, then it doesn't matter which
choice we make since subranges of CARDINAL and INTEGER are assignment
compatible (section 9.1).

  /charlie
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads