You are on page 1of 2

Programming Languages Jose M.

Montes – T00041911

Assignment

1. What is an enumeration type? Give an example.

An enumeration type is one in which all of the possible values, which are
named constants, are provided or enumerated in the definition.
Example (C#):

enum months {Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec}

2. What is an array slice? For what purposes are slices useful?

A slice of an array is some substructure of that array. if A is a


matrix, then the first row of A is one possible slice. A slice is a mechanism
for referencing part of an array as a unit.

Slices are used when working with data collections that might need to
expand or contract in the future, using a segment will ensure that the code is
error-free when trying to manipulate the set extent. And they are also used
when you need to store many elements or iterate them and want to be able
to easily modify those elements.

3. What is the difference between type equivalence and type compatibility?

In Type Equivalence, object can be used if its type and the type expected by
the context are equivalent, that is, the data type of the object is the same as
expected. Objects and contexts can be equivalent only when their types are
the same.

In type compatibility, type compatibility determines where objects of a


certain type can be used, that is, it indicates what type of data can be
contained in the object based on its type compatibility.
Compatibility is a more flexible relationship equivalence.
Objects and contexts can be compatible even when their types are different,
that is, if they can be used in the same context even after converting them
from one type to another, they can still be called compatible with the type.

4. What purpose(s) do types serve in a programming language?

• Types provide implicit context for many operations, so the developer


does not have to explicitly specify the context.
Programming Languages Jose M. Montes – T00041911

• Types limit the set of operations that can be performed on a valid


program, that is, the compiler will automatically know what type of
operations can be performed on the data. They prevent the developer
from adding a character and a record.

Resources:
[1] Sebesta, R. W. (2016). Concepts of Programming Languages (11th ed.). Edinburgh Gate,
England: Pearson.

[2] Gopher Guides (2020, February 7). Información sobre matrices y segmentos en Go. Retrieved
March 29, 2020, from https://www.digitalocean.com/community/tutorials/understanding-arrays-and-
slices-in-go-es
[3] Programming Language Chapter 7. (n.d.). Retrieved March 29, 2020, from
https://quizlet.com/252454661/programming-language-chapter-7-flash-cards/

You might also like