Programming
Language Project
Question
Set #5
Due:
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.
Array indexes are delimited by
parenthesis.
Answer
was was obtained from “Turing Reference Manual” by Ric Holt.
var number : array 1..10 of int
Answer was obtained from the “Turing Reference Manual” by
Ric Holt.
var number : array 1..10, 1..10 of int
Answer
was obtained from the “Turing Reference Manual” by Ric Holt.
Through experimenting the only
type that is legal is an int.
Yes, by using ‘init’.
Example: var number : array 1..3 of int
:= init(1, 2, 3)
As far as I have tested you must
initialize it as in the previous question, which initializes it item by item
From testing I have determined
that both are allowed in Turing.
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.
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.
Yes, my compiler gives an ‘Array
subscript is out of range’ error.