Programming Language Project

Question Set #5

Due: November 18, 2004 at start of class

Answers MUST be keyed in before printing

 

Name Christopher Payne            Programming Language  Object Oriented Turing

 

Note:  For each of these question sets, you should look first in the reports you were given.  You should then check the information on the Web or in a book.  If the information is not in the report, you should say so and then find it on the Web or in a book or by experimenting.  Save the results of your experiments. You may need them in a later assignment.

 

All of these questions are about arrays.  If your language doesn’t have arrays, you need to e-mail me and tell me what composite structure it does have (lists, records, tables, etc.) that you could use as an alternate.

 

  1. What symbols are used to delimit array indexes (i.e. ( ),  [ ], something else)?

Array indexes are delimited by parenthesis.

            Answer was was obtained from “Turing Reference Manual” by Ric Holt.

 

  1. Give an example of a one dimensional array declaration.

var number : array 1..10 of int    

      Answer was obtained from the “Turing Reference Manual” by Ric Holt.

 

  1. Give an example of a two-dimensional array declaration.

var number : array 1..10, 1..10 of int 

            Answer was obtained from the “Turing Reference Manual” by Ric Holt.

 

  1. What types are legal for subscripts?

Through experimenting the only type that is legal is an int.

 

  1. Can arrays be initialized when they have their storage allocated?

Yes, by using ‘init’. Example:  var number : array 1..3 of int := init(1, 2, 3)

 

  1. Can you initialize the entire array at once or do you have to initialize it item by item?

As far as I have tested you must initialize it as in the previous question, which initializes it item by item

 

  1. Are ragged or rectangualar multidimensional arrays allowed, or both?  

From testing I have determined that both are allowed in Turing.

 

  1. What kind of slices are allowed, if any?

Arrays can be assigned as a whole to an array of equivalent type that has the same size.  I could only specify one index instead

of a subrange of the indexes.  All other tests on slices failed.

 

  1. Are array sizes static or dynamic?

Array sizes can be either static or dynamic.  When declaring arrays as shown in question #2 arrays are static.  They can be dynamic by

declaring them using a variable in the following way:  

 

                                                var  value : int

                                                get vaule

                                                var number : array 1..value of int

 

The size is not known until run time and therefore dynamic.  This was tested on my compiler.

 

  1.  Does your language detect a reference to an out of bounds array subscript?

Yes, my compiler gives an ‘Array subscript is out of range’ error.