Concept of Programming Language Chapter 15

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

REVIEW QUESTIONS

1. Define functional form, simple list, bound variable and referential transparency.
– Functional form : one that either takes one or more functions as parameters or yields a function as its result.
Simple list : A list that does not include sublist.
Bound variable : A bound variable is a variable which never changes in the expression after being bound to an actual parameter value at the time evaluation of the lambda expressions begin.
Referential transparency : A state where execution of function always produces the same result when given the same parameters.

2. What does a lambda expression specify?
The predicate function is often given as a lambda expression, which in ML is defined exactly like a function, except with the fn reserved word, instead of fun, and of course the lambda expression is nameless.

3. What data types were parts of the original LISP ?
– atoms and lists

4. In what common data structure are LISP lists normally stored ?
– As linked list structure in which each node has two pointers.

5. Explain why QUOTE is needed for a parameter that is a data list.
To avoid evaluating a parameter, it is first given as a parameter to the primitive function QUOTE, which simply returns it without change.

6. What is a simple list?
A list which membership of a given atom in a given list that does not include sublists.

7. What does the abbreviation REPL stand for?
REPL stand for read-evaluate-print loop.

8. What are the three parameters to IF ?
– a predicate expression, a then expression, and else expression.

11. What are the two forms of DEFINE?
The simplest form of DEFINE is one used to bind a name to the value of an expression. This form is
(DEFINE symbol expression)
The general form of such a DEFINE is
(DEFINE (function_name parameters)
(expression)
)

13. Why are CAR and CDR so named?
The names of the CAR and CDR functions are peculiar at best. The origin of these names lies in the first implementation of LISP, which was on an IBM 704 computer. The 704’s memory words had two fields, named decrement and address, that were used in various operand addressing strategies. Each of
these fields could store a machine memory address. The 704 also included two machine instructions, also named CAR (contents of the address part of a register) and CDR (contents of the decrement part of a register), that extracted the associated fields. It was natural to use the two fields to store the two pointers
of a list node so that a memory word could neatly store a node. Using these conventions, the CAR and CDR instructions of the 704 provided efficient list selectors. The names carried over into the primitives of all dialects of LISP.

18. What is tail recursion? Why is it important to define functions that use recursion to specify repetition to be tail recursive?
A function is tail recursive if its recursive call is the last operation in the function. This means that the return value of the recursive call is the return value of the nonrecursive call to the function. It is important to specify repetition to be tail recursive because it is more efficient(increase the efficiency).

30. What does partial evaluation mean ?
– The function is evaluated with actual parameters for one or more of the leftmost formal parameters.

31. Define reader macros.
– A textual notation introduced by dispatch on one or two characters that defines special-purpose syntax

Continue reading

Concept of Programming Language Chapter 14

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

REVIEW QUESTIONS

2. When is an exception thrown or raised ?
– When an event associated with an exception occurs

3. What are the advantages of having support for exception handling built in to a language ?

– Without built-in exception handling, the code to detect error condition can be a clutter to the program. Existence of built-in exception handling would simplify a source program.

4. Give an example of hardware-detectable execution.

– Division by zero

5. What does it mean for an exception to be bound to an exception handler ?

– A specific exception is to be handled by a specific exception handler also, because different exceptions are to be treated differently.

6. What is exception propagation in Ada ?

– A powerful tool for constructing more reliable software systems.

11. are they any predefined exceptions in Ada?
Yes, they are.

12. What is the use of Suppress pragma in Ada?
The suppress pragma is used to disable certain run-time checks that
are parts of the built-in exceptions in Ada.

14. What is the name of all C++ exception handlers?
Try clause.

30. In which version were assertions added to Java?
Assertions were added to Java in version 1.4.

31. What is the use of the assert statement?
The assert statement is used for defensive programming. A program may be written with many assert statements, which ensure that the program’s computation is on track to produce correct results.

32. What is event-driven programming?
Event-driven programming is a programming where parts of the program are executed at completely unpredictable times, often triggered by user interactions with the executing program.

33. What is the purpose of a Java JFrame?
The JFrame class defines the data and methods that are needed for frames. So, a class that uses a frame can be a subclass of JFrame. A JFrame has several layers, called panes.

34. What are the different forms of assert statement?
There are two possible forms of the assert statement:
assert condition;
assert condition : expression;

Continue reading

Concept of Programming Language Chapter 13

Name: WIlliam Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

REVIEW QUESTIONS
1. What are the three possible levels of concurrency in programs ?
– Instruction level, Statement level, and Unit level

2. Describe the logical architecture of an SIMD computer.
– In an SIMD computer, each processor has its own local memory. One processor controls the operation of the other processors. Because all of the processors, except the controller, execute the same instruction at the same time, no synchronization is required in the software.

3. Describe the logical architecture of an MIMD computer.
-Each processor in an MIMD computer executes its own instruction stream. MIMD computers can appear in two distinct configurations: distributed and shared memory systems. The distributed MIMD machines, in which each processor has its own memory, can be either built in a single chassis or distributed, perhaps over a large area. The shared-memory MIMD machines obviously must provide some means of synchronization to
prevent memory access clashes.

4. What level of program concurrency is best supported by SIMD computers ?
-Instruction concurrency level

5. What level of program concurrency is best supported by MIMD computers ?
-Unit concurrency level.

7. What is the difference between physical and logical concurrency?

There are two distinct categories of concurrent unit control. The most natural category of concurrency is that in which, assuming that more than one processor is available, several program units from the same program literally execute simultaneously. This is physical concurrency. A slight relaxation of this concept of concurrency allows the programmer and the application software to assume that there are multiple processors providing actual concurrency, when in fact the actual execution of programs is taking place in interleaved fashion on a single processor. This is logical concurrency.

8. what is the work of a scheduler?

A run-time system program called a scheduler manages the sharing of processors among the tasks.

9. Give some examples of languages which can be used for synchronization.
– Ada 95, Java, C#, F#, Python and Ruby

10. When is a task in a blocked state ?
– When its execution is interrupted by one of several different events

30. What is purpose of an Ada terminate clause?

The purpose of an Ada terminate clause is to mark that the task is finished with its job but is not yet terminated.

34. What does the Java sleep method do?

Sleep method blocks the the thread.

35. What does the Java yield method do?

Yield method surrenders the processor voluntarily as a request from the running thread.

55. What is Concurrent ML?

Concurrent ML is an extension to ML that includes a fform of threads and a form of synchronous message passing to support concurrency.

56. What is the use of the spawn primitive of CML?

The use of Spawn primitive of CML is to create a thread.

57. What is the use of subprograms BeginInvoke and EndInvoke in F#?

The use of subprograms BeginInvoke and Endinvoke in F# is to call threads asynchronously.

58. What is the use of the DISTRIBUTE and ALIGN specification of HPC?

The use of DISTRIBUTE and ALIGN specification of HPC is to provide information to the compiler on machines that do not share memory, that is, each processor has its own memory.

Continue reading

Concept of Programming Language Chapter 12

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

Review Questions

1. Name two functional languages that support object-oriented programming.
– C++ and Objective-c

2. What are the problems associated with programming using abstract data types ?
– in nearly all cases, the features and capabilities of the existing type are not quite right for the new
use. The old type requires at least some minor modifications.

3. What is the advantage of inheritance ?
– Allows to reuse ADT and modificate it without actually modifying the original ADT and program organization problem.

4. What is message protocol ?
– Entire collection of methods of an object.

5. What is an overriding method ?
– A new method that overrides inherited method(i.e. Changes how the method behaviors compared to the inherited one)

7. What is dynamic dispatch?

Dynamic dispatch is the third characteristic (after abstract data types and inheritance) of object-oriented programming language which is a kind of polymorhphism provided by the dynamic binding of messages to method definitions.

8. What is an abstract method? What is an abstract class?
For example, suppose a program defined a Building class and a collection of subclasses for specific types of buildings, for instance, French_Gothic. It probably would not make sense to have an implemented draw method in Building. But because all of its descendant classes should have such an implemented method, the protocol (but not the body) of that method is included in Building. Such a method is often called an abstract method ( pure virtual method in C++). A class that includes at least one abstract method is called an abstract class (abstract base class in C++).

10. What is an inner class?
Inner classes are non-static classes that are nested directly in another class.

12. From where are Smalltalk objects allocated?

Smalltalk objects are allocated from the heap and are referenced through reference variables, which are implicitly dereferenced.

15. What kind of inheritance, single or multiple, does Smalltalk support?

Smalltalk supports single inheritance; it does not allow multiple inheritance.

18. From where can C++ objects be allocated?
The objects of C++ can be static, stack dynamic, or heap dynamic. Explicit deallocation using the delete operator is required for heap-dynamic objects, because C++ does not include implicit storage reclamation.

19. How are C++ heap-allocated objects deallocated?

C++ heap-allocated objects are deallocated using destructor.

25. What is mixins in objective-C?
Mixins are sometimes used to add certain functionalities to different classes. And, of course, the class still has a normal superclass from which it inherits members. So, mixins provide some of the benefits of multiple inheritance, without the naming collisions that could occur if modules did not require module names on their functions.

29. Does Objective-C support multiple inheritance?

No Objective-C doesn’t support it. (It supports only single inheritance).

Continue reading

Concept of Programming Language Chapter 11

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

Review Questions

2. Define abstract data type.

data type that satisfies the following conditions:

-The representation of objects of the type is hidden from the program units that use the type, so the only direct operations possible on those objects are those provided in the type’s definition.

-The declarations of the type and the protocols of the operations on objects of the type, which provide the type’s interface, are contained in a single syntactic unit. The type’s interface does not depend on the representation of the objects or the implementation of the operations. Also, other program units are allowed to create variables of the defined type.

5. What are the language design issues for abstract data types ?

– ADTs must have a function that allows a user to modify a value inside that data type. Although the method is public, the value itself must be private.

6 . Explain how information hiding is provided in Ada package.
Data type representations can appear in the package specification but be hidden from clients by putting them in the private clause of the package. The abstract type itself is defined to be private in the public part of the package specification. Private types have built-in operations for assignment and comparison for equality and inequality.

10. What is the use of the Ada with clause ?

– To make the names defined in external packages visible

11. What is the use of the Ada use clause ?

– To eliminate the need for explicit qualification of the references to entities from the named package.

12. What is the fundamental difference between a C++ class and an Ada package?

Ada packages are more generalize encapsulations that can define any number of types.

15. What is the purpose of a C++ destructor?
Destructors are often used as a debugging aid, in which case they simply display or print the values of some or all of the object’s data members before those members are deallocated. The name of a destructor is the class’s name, preceded by a tilde (~).

16. What are the legal return types of a destructor?
Neither constructors nor destructors have return types, and neither use return statements. Both constructors and destructors can be explicitly called.

21. What are initializers in Objective-C?
Initializers are constructors.

26. Why does Java not have destructors ?

– Because Java has its own implicit garbage collection.

27. Where are all java methods defined?
Methods in Java must be defined completely in a class.

Continue reading

Concept of Programming Language Chapter 10

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

Review Questions

1. What is the definition used in this chapter for “simple” subprograms?
By “simple” they mean that subprograms cannot be nested and all local variables are static.

2. Which of the caller or callee saves execution status information?
The last three actions of a call clearly must be done by the caller. Saving the execution status of the caller could be done by either.

4. What is the task of a linker ?

– find files that contain the translated subprograms referenced in that program and load them into memory, set target addresses of all calls to those subprograms in the main program to the entry addresses of those subprograms.

6.     What are the two potential problems with the static chain methods?

  • A nonlocal reference is slow if the number of scopes between the reference and the declaration of the referenced variable is large
  • Time-critical code is difficult, because the costs of nonlocal references are not equal, and can change with code upgrades and fixes

8. What kind of machines often use registers to pass parameters ?

– RISC Machines

10. Define static chain, static_depth, nesting_depth,and chain_offset.

-static chain : a chain of static links that connect certain activation record instances in the stack.

-static_depth : integer associated with a static scope that indicates how deeply it is nested in the outermost scope.

-nesting_depth : difference between static_depth of a subprogram containing reference to x and the static_depth of a subprogram containing the declaration of x.

-chain_offset : number of links to the correct activation record instance

12. How are references to variables represented in the static-chain method ?

-It is represented by static_depth.

14.  Compare the efficiency of the deep access method to that of the shallow access method, in term of both call and nonlocal access?

The deep access methods provides fast subprogram linkage, but references to nonlocal, especially references to distant nonlocals (in term of the call chain), are costly. The shallow access methods provide much faster references to nonlocals, especially distant nonlocals, but are more costly in term of subprogram linkage.

Continue reading

Concept of Programming Language Chapter 9

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

Review Questions

1. What are three general characteristics of subprograms ?
– each subprograms has a single entry point
– the calling program unit is suspended during the execution of the called subprogram, which implies that there is only one subprogram in execution at any given time.
– Control always returns to the caller when the subprogram execution terminates.

2. What does it mean for a subprogram to be active ?
– if it has been called and started execution but the execution is not completed yet.

3. What is given in the header of a subprogram ?
– specifies that the following syntactic unit is a subprogram definition of some particular kind, provides name of the subprogram, optionally specifies a list of parameters

4. What characteristics of Python subprograms sets them apart from those of other languages ?
– function def statements are executable

5. What languages allow a variable number of parameters ?
– C,C++,Perl JavaScript, and Lua

10.  In what ways can aliases occur with pass-by-reference parameters?

Aliases can be occurring because pass-by-reference makes access paths available to the called subprograms.

17.  What is parametric polymorphism?

Parametric polymorphism is provided by a subprogram that takes a generic parameter that is used in a type expression that describes the types of the parameters of the subprogram. Both Ada and C++ provides a kind of compile-time parametric polymorphism.

24. What is an overloaded subprogram?
An overloaded subprogram is a subprogram that has the same name as another subprogram in the same referencing environment.

25. What is ad hoc binding?
Ad hoc binding is when the environment of the call statement that passed the subprogram as an actual parameter.

26. What is multicast delegate?
All of the methods stored in a delegate instance are called in the order in which they were placed in the instance. This is called a multicast delegate

Continue reading

Concept of Programming Language Chapter 8

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

Review Questions

1. What is the definition of control structure ?
Control structure is a control statement and the collection of statements whose execution it controls.

2. What did Bohm and Jocopini prove about flowcharts?

It was proven that all algorithms that can be expressed by flowcharts can be coded in a programming languages with only two control statements: one for choosing between two control flow paths and one for logically controlled iterations.

3. What is the definition of block?

In Ruby, block is a sequence of code, delimited by either breves or the do and and reserved words.

6. What is unusual about Python’s design of compound statements ?
Python uses indentation to specify compound statements. For example,
if x > y :
x = y
print “case 1″
equally indent statements are grouped as one compound statement.

7. Under what circumstances must an F# selector have an else clause ?
If the expression returns a value, it must have an else clause.

14. What are the design issues for all iterative control statements ?
-How is the iteration controlled ?
-Where should the control mechanism appear in loop statement?

15.  What are the design issues for counter-controlled loop statements?

 

  • What are the type and scope of the loop variable?
  • Should it be legal for the loop variable or loop parameters to be changed in the loop, and if so, does the change affect loop control?
  • Should the loop parameters be evaluated only once, or once for every iteration?

19. What does the range function in phyton do?
range takes one, two, or three parameters. The following examples demonstrate
the actions of range:
range(5) returns [0, 1, 2, 3, 4]
range(2, 7) returns [2, 3, 4, 5, 6]
range(0, 8, 2) returns [0, 2, 4, 6]

22. What is the main reason user-located loop control were invented?
In some situations, it is convenient for a programmer to choose a location for loop control other than the top or bottom of the loop body. As a result, some languages provide this capability. A syntactic mechanism for user-located loop control can be relatively simple, so its design is not difficult. Such loops have the structure of infinite loops but include user-located loop exits.

 

23. What are the design issues for user-located loop control mechanisms?
The design issues for such a mechanism are the following:
• Should the conditional mechanism be an integral part of the exit?
• Should only one loop body be exited, or can enclosing loops also be exited?

Continue reading

Concept of Programming Language Chapter 7

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

REVIEW QUESTIONS

1. Define operator precedence and operator associativity.
The operator precedence rules for expression evaluation partially define
the order in which the operators of different precedence levels are evaluated.
An operator can have
either left or right associativity, meaning that when there are two adjacent
operators with the same precedence, the left operator is evaluated first or the
right operator is evaluated first, respectively.

2. What is a ternary operator?
ternary, meaning it has three operands.

3. What is a prefix operator?
prefix, which means they precede their operands.

6. What associativity rules are used by APL?
the order of evaluation of operators in APL expressions is
determined entirely by the associativity rule, which is right to left for all operators.

8. Define functional side effect.
occurs when
the function changes either one of its parameters or a global variable.

10. What is a conditional expression?
if-then-else statements can be used to perform a conditional expression
assignment.

11. What is an overloaded operator?
This multiple
use of an operator is called operator overloading and is generally thought to
be acceptable, as long as neither readability nor reliability suffers.

Continue reading

Concept of Programming Language Chapter 6

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

REVIEW QUESTIONS

1. What is a descriptor?
A descriptor is the collection of the attributes of a variable. In
an implementation, a descriptor is an area of memory that stores the attributes
of a variable.

3. What are the design issues for character string types?
The two most important design issues that are specific to character string types are the following:
– Should strings be simply a special kind of character array or a primitive type?
– Should strings have static or dynamic length?

4. Describe the three string length options.
-static length string: the length can be static and set when the string is created.
-limited dynamic length strings: to allow strings to have varying length up to a
declared and fixed maximum set by the variable’s definition.
-dynamic length strings: to allow strings to have varying length with no maximum,
as in JavaScript, Perl, and the standard C++ library.

5. Define ordinal, enumeration, and subrange types.
-An ordinal type is one in which the range of possible values can be easily
associated with the set of positive integers.
-An enumeration type is one in which all of the possible values, which are
named constants, are provided, or enumerated, in the definition.
-A subrange type is a contiguous subsequence of an ordinal type.

8. What are the desgin issues for arrays?
The primary design issues specific to arrays are the following:
• What types are legal for subscripts?
• Are subscripting expressions in element references range checked?
• When are subscript ranges bound?
• When does array allocation take place?
• Are ragged or rectangular multidimensioned arrays allowed, or both?
• Can arrays be initialized when they have their storage allocated?
• What kinds of slices are allowed, if any?

17. Define row major order and column major order.
-In row major order, the
elements of the array that have as their first subscript the lower bound value of
that subscript are stored first, followed by the elements of the second value of
the first subscript, and so forth.
-In column major order, the elements of an array that have as their last subscript
the lower bound value of that subscript are stored first, followed by the
elements of the second value of the last subscript, and so forth.

18. What is an access function for an array?
The access function for a multidimensional array is the mapping of its
base address and a set of index values to the address in memory of the element
specified by the index values.

20. What is the structure of an associative array?
In an
associative array, however, the user-defined keys must be stored in the structure.
So each element of an associative array is in fact a pair of entities, a key and a
value.

31. Define union, free union, and discriminated union.
-A union is a type whose variables may store different type values at different
times during program execution.
-free unions, because programmers
are allowed complete freedom from type checking in their use.
-discriminated union: Type checking of unions requires that each union construct include a type
indicator.

43. What is a compatible type?
A compatible type is one that either is legal for
the operator or is allowed under language rules to be implicitly converted by
compiler-generated code (or the interpreter) to a legal type.

44. Define type error.
A type error is the application of an operator to an operand of an inappropriate
type.

47. What is a nonconverting cast?
No actual
conversion takes place; it is merely a means of extracting the value of a variable of one type and using it as if it were of a different type.

48. What languages have no type coercions?
ML and F#.

Continue reading

Concepts of Programming Language Chapter 5

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

REVIEW QUESTIONS

7. Define binding and binding time.
A binding is an association between an attribute and an entity, such as
between a variable and its type or value, or between an operation and a symbol.
The time at which a binding takes place is called binding time.

10. What are the advantages and disadvantages of implicit declarations?
implicit declarations
can be detrimental to reliability because they prevent the compilation
process from detecting some typographical and programmer errors.

11. What are the advantages and disadvantages of dynamic type binding?
The primary advantage of
dynamic binding of variables to types is that it provides more programming
flexibility.

The disadvantage is it causes
programs to be less reliable, because the error-detection capability of the
compiler is diminished relative to a compiler for a language with static type
bindings.

13. Define lifetime, scope, static scope, and  dynamic scope.

-Lifetime is the time during which the variable is bound to a specific memory location.
-Scope is the range of statements in which the variable is visible.
-Static scope is the scope of variable that can be statically determined inside subprograms and prior to execution.
-Dynamic scope is the scope that is based of calling sequence of subprograms, not on their spatial relationship to each other and can be determined only at run time.

18. What is a block?
Block is a section of a code.

22. What are the advantages and disadvantages of dynamic scoping?
during the time span beginning when a subprogram begins its execution
and ending when that execution ends, the local variables of the subprogram
are all visible to any other executing subprogram, regardless of its textual
proximity or how execution got to the currently executing subprogram.

Dynamic scoping is based on the calling sequence of subprograms, not
on their spatial relationship to each other.

Continue reading

Concepts of Programming Language Chapter 4

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

REVIEW QUESTIONS

2. Explain the three reasons why lexical analysis is separated from syntax
analysis.

1. Simplicity—Techniques for lexical analysis are less complex than those
required for syntax analysis, so the lexical-analysis process can be simpler
if it is separate. Also, removing the low-level details of lexical analysis
from the syntax analyzer makes the syntax analyzer both smaller and
less complex.
2. Efficiency—Although it pays to optimize the lexical analyzer, because
lexical analysis requires a significant portion of total compilation time,
it is not fruitful to optimize the syntax analyzer. Separation facilitates
this selective optimization.
3. Portability—Because the lexical analyzer reads input program files
and often includes buffering of that input, it is somewhat platform
dependent. However, the syntax analyzer can be platform independent.
It is always good to isolate machine-dependent parts of any software
system.

3. Define lexeme and token.
– Lexeme is an abstract unit of morphological analysis in linguistics, that roughly corresponds to a set of forms taken by a single word.
– Token is the the internal codes for categories.

6. What is a state transition diagram?
A directed graph.

8. What are the two distinct goals of syntax analysis?
-checking the input program to determine whether it is syntactically correct
-producing a complete parse tree.

9. Describe the differences between top-down and bottom-up parsers.
top-down, in which the tree is built
from the root downward to the leaves, and bottom-up, in which the parse tree
is built from the leaves upward to the root.

18. What is left factoring?
Left factoring is the action taken when a grammar leads backtracking while making parsing/syntax tree.

23. Describe three advantages of LR parsers.
– LR parsers can be constructed to recognize virtually all programming-language constructs for which context-free grammars can be written.

– The LR parsing method is the most general non-backtracking shift-reduce parsing method known, yet it can be implemented as efficiently as other shift-reduce methods.

– The class of grammars that can be parsed using LR methods is a proper subset of the class of grammars that can be parsed with predictive parsers.

Continue reading

Concepts of Programming Language Chapter 3

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

REVIEW QUESTIONS

1. Define syntax and semantics.
– syntax of a programming language is the form of its expressions, statements, and program
units.
– semantics is the meaning of those expressions, statements, and program units.

2. Who are language descriptions for?
Language descriptions is for programming language implementors.

5. What is the difference between a sentence and a sentential form?
– A sentence is a language, whether natural (such as English) or artificial (such as Java), is a set
of strings of characters from some alphabet.
– A sentential form is an each successive string in the
sequence is derived from the previous string by replacing one of the nonterminals
with one of that nonterminal’s definitions.

6. Define a left-recursive grammar rule.
When a grammar rule has its LHS also appearing at the beginning of its
RHS, the rule is said to be left recursive. This left recursion specifies left
associativity.

7. What three extensions are common to most EBNFs?
– the denotes an optional part of an RHS, which is delimited by
brackets.
– the use of braces in an RHS to indicate that the
enclosed part can be repeated indefinitely or left out altogether.
– deals with multiple-choice options.

8. Distinguish between static and dynamic semantics.
– The static semantics of a language is only indirectly
related to the meaning of programs during execution; rather, it has to do
with the legal forms of programs.
– no universally accepted notation or approach has been devised for dynamic semantics.

10. What is the difference between a synthesized and an inherited attribute?
Synthesized attributes are used to pass semantic information up a parse tree, while inherited attributes
pass semantic information down and across a tree.

12. What is the primary use of attribute grammars?
To describe both the syntax and the static semantics of programs.

15. Describe the two levels of uses of operational semantics.
At the highest level, the interest is in the final result of the execution of a complete program.
This is sometimes called natural operational semantics.
At the lowest level, operational semantics can be used to determine the precise meaning of a program
through an examination of the complete sequence of state changes that
occur when the program is executed.

18. Which semantics approach is most widely known?
Denotational semantics is the most rigorous and most widely known formal
method for describing the meaning of programs. It is solidly based on recursive
function theory.

Continue reading

Concpet of Programming Language Chapter 2

Name: William Gunawan

NIM: 1601211306

Instructor: Tri Djoko Wahjono

REVIEW QUESTIONS

1. In what year was Plankalkül designed? In what year was that design
published?
Plankalkül was designed in 1945 and was published in 1972.

2. Mention an interesting feature of Zuse’s programs.
One of the most interesting features of Zuse’s programs was the inclusion
of mathematical expressions showing the current relationships between program
variables. These expressions stated what would be true during execution
at the points in the code where they appeared.

3. What does Plankalkül mean?
program calculus.

22. On what language was COBOL based?
FLOW-MATIC

23. In what year did the COBOL design process begin?
1959

28. PL/I was designed to replace what two languages?
Fortran and COBOL.

29. For what new line of computers was PL/I designed?
IBM Systems/360.

31. What innovation of data structuring was introduced in ALGOL 68 but is
often credited to Pascal?
User-defined data types.

32. What design criterion was used extensively in ALGOL 68?
orthogonality.

33. What language introduced the case statement?
ALGOL-W

42. What three concepts are the basis for object-oriented programming?
Inheritance, Polymorphism, Encapsulation

52. What array structure is included in C# but not in C, C++, or Java?
Rectangular arrays are included in C#, but not in C, C++, or Java.

57. What data types does Java support?
byte
short
int
long
float
double
char
String (or any object)
boolean

60. How does Java provide storage deallocation?
Java uses implicit storage deallocation for its objects, often called garbage collection.
This frees the programmer from needing to delete objects explicitly when they are no longer needed. Programs written in languages that do not have garbage collection often suffer from what is sometimes called memory leakage, which means that storage is allocated but never deallocated. This can obviously lead to eventual depletion of all available storage.

65. What are the inputs to an XSLT processor?
an XML data document and an XSLT document

66. What is the output of an XSLT processor?
another XML document

69. Where are .jsp files executed?
On a webserver.
Continue reading

Concept of Programming Language Chapter 1

NIM: 1601211306

Name: William Gunawan

Instructor: Tri Djoko Wahjono

Review questions

3. Fortran (Formula Translating)
4. COBOL (COmmon Business-Oriented Language)
5. LISP
6. The UNIX operating system is written almost entirely in C
9. Although C has two kinds of structured
data types, arrays and records (structs), records can be returned from
functions but arrays cannot.
15. aliasing is having two or more distinct names that can be
used to access the same memory cell.
16. The ability of a program to intercept run-time errors (as well as other unusual
conditions detectable by the program), take corrective measures, and then
continue is an obvious aid to reliability.
17. Readability affects reliability in both the writing and maintenance phases
of the life cycle. Programs that are difficult to read are difficult both to write
and to modify.

Continue reading