Friday, June 28, 2013

Concepts of Programming Languages Chapter 16


Concepts of Programming Languages Chapter 16


Name            : Erland
NIM              : 1601218035
Lecturer       : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment  : Concept of programming languages Chapter 16

Review Question
        1. What are the three primary uses of symbolic logic in formal logic ?
- to express propositions, to express the relationships between propositions, and todescribe how new propositions can be inferred from other propositions thatare assumed to be true.

         2. What are the two parts of a compound term ?
- functor and and ordered list of of parameters

         3. What are the two modes in which a proposition can be stated ?
- one in which a proposition is defined to be true and one in which that the proposition is something to be determined.

        4. What is general form of a proposition in clausal form ?
-B1 U B2 U . . . U Bn C A1 n A2 n . . . n Am

        5. What are antecedents ? Consequents ?
- Antecedents are right side of a clausal form proposition. Consequent is left side of a clausal form propositions

        6. Give general definitions of resolution and unification
- Resolution : inference rule that allows inferred propositions to be computed from given propositions, thus providing a method with potential application to automatic theorem proving.-Unification : Process of determining useful values for variables.

        7. What are the forms of Horn clauses?
Headed and headless.

        9. What does it mean for a language to be nonprocedural?
Programs do not state now a result is to be computed, but rather the form of the result

Problem Set

        1. Compare the concept of data typing in Ada with that of Prolog.
Ada variables are statically bound to types.  Prolog variables are bound to types only when they are bound to values.  These bindings take place during execution and are tempoarary.

         2. Describe how a multiple-processor machine could be used to implement 
             resolution. Could Prolog, as currently defined, use this method?
On a single processor machine, the resolution process takes place on the rule base, one rule at a time, starting with the first rule, and progressing toward the last until a match is found.  Because the process on each rule is independent of the process on the other rules, separate processors could concurrently operate on separate rules.  When any of the processors finds a match, all resolution processing could terminate.

         8. Critically comment on the following statement : “ Logic programs 
             are nonprocedural”
- It is true, because logical programs use lots of different processes based on its conditions. If a certain logical requirement is true, then a program will execute the corresponding process, instead of procedurally executing the statements.

         9. From a book on Prolog, learn and write a description of a monkey-banana 
              prolem. Why does Prolog allow this problem to exist in its implementation ?
- The problem is defined as this : a monkey is in a room. Suspended from the ceiling is a bunch of bananas, beyond the monkey’s reach. However, in the room there are also a chair and a stick. The ceiling is just the right height so that a monkey standing on a chair could knock the bananas down with the stick. The monkey knows how to move around, carry other things around, reach for the bananas, and wave a stick in the air. What is the best sequence of actions for the monkey?It exists to create a variation in output of Prolog. As Prolog is an AI programming language, a variation might be needed in AI output to make them respond relevant to the situation.

Concepts of Programming Languages Chapter 15


Concepts of Programming Languages Chapter 15


Name            : Erland
NIM              : 1601218035
Lecturer       : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment  : Concept of programming languages Chapter 15

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 ?
- parameters and the mapping of a function.

         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 return lists or atoms without changing them.

          6. What is a simple list ?
- A list that does not include a sublist.

          7. What does the abbreviation REPL stand for ?
- Infinite Read-Evaluate-Print Loop

           27. What is the use of the fn reserved word in ML?

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.

           29. What is a curried function?

Curried functions are interesting and useful because new functions can be constructed from them by partial evaluation.

          30. What does partial evaluation mean?

Partial evaluation means that the function is evaluated with actual parameters for one or more of the leftmost formal parameters.

          31. Define reader macros.

Reader macros or read macros, that are expanded during the reader phase of a LISP languageprocessor. A reader macro expands a specific character into a string of LISP code. For example, the apostrophe in LISP is a read macro that expands to a call to QUOTE. Users can define their own reader macros to create other shorthand constructs.

         32.What is the use of evaluation environment table?
A table called the evaluation environment stores the names of all implicitly and explicitly declared identifiers in a program, along with their types. This is like a run-time symbol table. When an identifier is declared, either implicitly or explicitly, it is placed in the evaluation environment.

Problem Set

         4. Refer to a book on Haskell programming and discuss the feature of Haskell.
- Haskell features lazy evaluation, pattern matching, list comprehension, type classes, and type polymorphism. It is a purely functional language, which means that in general, functions in Haskell do not have side effects. There is a distinct construct for representing side effects, orthogonal to the type of functions. A pure function may return a side effect which is subsequently executed, modeling the impure functions of other languages.Haskell has a strong, static type system based on Hindley–Milner type inference. Haskell’s principal innovation in this area is to add type classes, which were originally conceived as a principled way to add overloading to the language, but have since found many more uses.The construct which represents side effects is an example of a monad. Monads are a general framework which can model different kinds of computation, including error handling, nondeterminism, parsing, and software transactional memory. Monads are defined as ordinary datatypes, but Haskell provides some syntactic sugar for their use.



         8.How is the functional operator pipeline(|>)used in F#?

The pipeline operator is a binary operator that sends the value of its left operand, which is an expression, to the last parameter of the function call, which is the right operand. It is used to chain together function calls while flowing the data being processed to each call. Consider the following example code, which uses the high-order functions filter and map:
let myNums = [1; 2; 3; 4; 5]
let evensTimesFive = myNums
|> List.filter (fun n −> n % 2 = 0)
|> List.map (fun n −> 5 * n)



          9. What does the following Scheme function do?
(define (y s lis)(cond((null? lis) ‘() )((equal? s (car lis)) lis)(else (y s (cdr lis)))))y returns the given list with leading elements removed up to but not including the first occurrence of the first given parameter.

Concepts of Programming Languages Chapter 14


Concepts of Programming Languages Chapter 14


Name            : Erland
NIM              : 1601218035
Lecturer       : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment  : Concept of programming languages Chapter 14

Review Question

       1. Define exception, exception handler, raising an exception, disabling 
           an exception, continuation, finalization, and built-in exception.
           Answer:
An exception is an unusual event that is detectable by either hardware or software and that may require special processing. The special processing that may be required when an exception is detected is called exception handling. The processing is done by a code unit or segment called an exception handler. An exception is raised when its associated event occurs. In some situations, it may be desirable to ignore certain hardware-detectable exceptions—for example, division by zero—for a time. This action would be done by disabling the exception. After an exception handler executes, either control can transfer to somewhere in the program outside of the handler code or
Program execution can simply terminate. We term this the question of control continuation after handler execution, or simply continuation. In some situations, it is necessary to complete some computation regardless of how subprogram execution terminates. The ability to specify such a computation is called finalization. Built-in exceptions have a built-in meaning, it is generally inadvisable to use these to signal program-specific error conditions.  Instead we introduce a new exception using an exception declaration, and signal it using a raise expression when a run-time violation occurs.  That way we can associate specific exceptions with specific pieces of code, easing the process of tracking down the source of the error.

       2. When is an exception thrown or raised ?
            Answer:
- When an event associated with an exception occurs

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


- 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.
             Answer:
- Division by zero

        5. What does it mean for an exception to be bound to an exception handler ?
            Answer:
- 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 ?
              Answer:
- A powerful tool for constructing more reliable software systems.

         7. Where are unhandled exceptions propagated in Ada if raised in a 
             subprogram?A block? A package body? A task?
             Answer:
When an exception is raised in a block, in either its declarations or executable statements, and the block has no handler for it, the exception is propagated to the next larger enclosing static scope, which is the code that “called” it. The point to which the exception is propagated is just after the end of the block in which it occurred, which is its “return” point. When an exception is raised in a package body and the package body has no handler for the exception, the exception is propagated to the declaration section of the unit containing the package declaration. If the package happens to be a library unit (which is separately compiled), the program is terminated.
If an exception occurs at the outermost level in a task body (not in a nested block) and the task contains a handler for the exception, that handler is executed and the task is marked as being completed. If the task does not have a handler for the exception, the task is simply marked as being completed; the exception is not propagated. The control mechanism of a task is too complex to lend itself to a reasonable and simple answer to the question of where its unhandled exceptions should be propagated.

       8. Where does execution continue after an exception is handled in Ada ?
            Answer:
- Control simply continues after the exception clause.

        10. What are the four exceptions defined in the Standard package of Ada ?
              Answer:
- Constraint_Error,Program_Error,Storage_Error, and Tasking_Error.

         11. Are there any predefined exceptions in Ada ?
               Answer:
- Yes, there are, for example Ada.Text_IO defines the End_Error exception.

          12. What is the use of Suppress pragma in Ada ?
                Answer:
- Run-time checks that are parts of built-in exceptions can be disabled in Ada programs

Problem Set

           1. What mechanism did early programming languages provide to 
                detect to attempt to deal with errors ?


- There were no possibility for the user program to detect or attempt to deal with errors. In case if error happens, the program will be terminated and control will be transferred to the operating system.

          2. Describe the approach for the detection of subscript range errors used 
               in C and Java.


- C does not check subscript ranges. While in Java, compilers usually generate a code to check the correctness of every subscript expression. If any exception generates, an unchecked exception is thrown.



          6. In languages without exception-handling facilities, it is common to have most  
              subprograms include an “error” parameter, which can be set to some value  
              representing “OK” or some other value representing “error in procedure.” 
               What advantage does a linguistic exception-handling facility like that of Ada
               have over this method?
There are several advantages of a linguistic mechanism for handling exceptions, such as that found in Ada, over simply using a flag error parameter in all subprograms.  One advantage is that the code to test the flag after every call is eliminated.  Such testing makes programs longer and harder to read.  Another advantage is that exceptions can be propagated farther than one level of control in a uniform and implicit way.  Finally, there is the advantage that all programs use a uniform method for dealing with unusual circumstances, leading to enhanced readability.



          7. In a language without exception handling facilities, we could send an 
              error-handling procedure as a parameter to each procedure that can 
              detect errors that must be handled. What disadvantages are there to 
              this method?


There are several disadvantages of sending error handling subprograms to other subprograms. One is that it may be necessary to send several error handlers to some subprograms, greatly complicating both the writing and execution of calls. Another is that there is no method of propagating exceptions, meaning that they must all be handled locally. This complicates exception handling, because it requires more attention to handling in more places.

Thursday, June 27, 2013

Concepts of Programming Languages Chapter 13


Concepts of Programming Languages Chapter 13


Name            : Erland
NIM              : 1601218035
Lecturer       : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment  : Concept of programming languages Chapter 13

Review Questions


       1.   What are the three possible levels of concurrency in programs?
             Answer :  
-Instruction level (executing two or more machine instructions simultaneously)
-Statement level (executing two or more high-level language statements simultaneously)
-Unit level (executing two or more subprogram units simultaneously)
       2. Describe the logical architecture of an SIMD computer.
            Answer : 
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. Perhaps the most widely usedSIMD machines are a category of machines called vector processors. They have groups of registers that store the operands of a vector operation in which the same instruction is executed on the whole group of operands simultaneously. Originally, the kinds of programs that could most benefit from this architecture were in scientific computation, an area of computing that is often the target of multiprocessor machines. However, SIMD processors are now used for a variety of application areas, among them graphics and video processing. Until recently, most supercomputers were vector processors.
       3. Describe the logical architecture of an MIMD computer.
             Answer :
Computers that have multiple processors that operate independently but whose operations can be synchronized are called Multiple-Instruction Multiple- Data (MIMD) computers. 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. Even distributed MIMD machines require synchronization to operate together on single programs. MIMD computers, which are more general than SIMD computers, support unit-level concurrency. The primary focus of this chapter is on language design for shared memory MIMD computers, which are often calledmultiprocessors.
      4.   What level of program concurrency is best supported by SIMD computers?
            Answer :
Statement-level concurrency
       5.   What level of program concurrency is best supported by MIMD computers?
             Answer : 
Unit-level concurrency is best supported by MIMD computers.
       7.   What is the difference between physical and logical concurrency?
             Answer : 
-Physical concurrency is several program units from the same program that literally execute simultaneously.
-Logical concurrency is multiple processors providing actual concurrency, when in fact the actual execution of programs is taking place in interleaved fashion on a single processor.
        8.   What is the work of a scheduler?
              Answer:
Scheduler manages the sharing of processors among the tasks.

        12. What is a heavyweight task? What is a lightweight task?
              Answer : 
Heavy weight task executes in its own address space. Lightweight task all run in the same address space.

       16. What is a task descriptor?
             Answer :
Task descriptor is a data structure that stores all of the relevant information about the execution state of a task.
       21. What is a binary semaphore? What is a counting semaphore?
             Answer : 
A binary semaphore is  a semaphore that requires only a binary-valued counter. A counting semaphore is a synchronization object that can have an arbitrarily large 
       30. What is purpose of an Ada terminate clause?
             Answer : 
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?
             Answer :
Sleep method blocks the the thread.
       35. what does the Java yield method do?
             Answer :
The yield method, which takes no parameters, is a request from the running thread to surrender the processor voluntarily. The thread is put immediately in the task-ready queue, making it ready to run. The scheduler then chooses the highest-priority thread from the task-ready queue. If there are no other ready threads with priority higher than the one that just yielded the processor, it may also be the next thread to get the processor.
      36. what does the Java join method do?
             Answer :
Java forces a method to delay its execution until the run method of another thread has completed its execution.

      37. What does the Java interrupt method do?
             Answer :
Interrupt becomes one way to communicate to a thread that it should stop.

       42. What kind of Java object is a monitor?
             Answer :
In Java, a monitor can be implemented in a class designed as an abstract data type, with the shared data being the type. Accesses to objects of the class are controlled by adding the synchronized modifier to the access methods.
      47. How are explicit locks supported in Java?
             Answer :
Java 5.0 introduced explicit locks as an alternative to synchronized method and blocks, which provide implicit locks. The Lock interface declares the lock, unlock, and tryLock methods. The predefined ReentrantLock class implements the Lock interface. To lock a block of code, the following idiom can be used:Lock lock = new ReentrantLock();. . .Lock.lock();try {// The code that accesses the shared data} finally {Lock.unlock();}
      48. What kinds of methods can run in a C# thread?
             Answer :
Rather than just methods named run, as in Java, any C# method can run in its own thread.
      55. What is Concurrent ML?
             Answer :
Concurrent ML (CML) is an extension to ML that includes a form of threads and a form of synchronous message passing to support concurrency. The language is completely described in Reppy (1999).
      56. What is the use of the spawn primitive of CML?
             Answer :
The use of Spawn primitive of CML is to create a thread.

Concepts of Programming Languages Chapter 12


Concepts of Programming Languages Chapter 12


Name            : Erland
NIM              : 1601218035
Lecturer       : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment  : Concept of programming languages Chapter 12

Review Questions


       1. Name two functional languages that support object oritented programming
             Answer :  
C++ and Java
       2. What are the problems associated with programming using abstract data type?
            Answer : 
– the features and capabilities of the existing type are not quite right for the new use.
– the type of definitions are all independent and are at the same level
       3. What is the advantage of inheritance?
             Answer :
programmers can begin with an existing abstract data type and design a modified descendant of it to fit a new problem requirement
       4. What is message protocol?
            Answer :
the entire collection of methods of an object
       5. What is an overriding method?
             Answer : 
A method that overrides the inherited method 
       6 .  Explain how information hiding is provided in Ada package.
             Answer : 
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.
        7.   What is dynamic dispatch?
              Answer:
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?
              Answer : 
An abstract method is an implemented method which all of descendant class should have and it is included in Building. An abstract class is  a class that includes at least one abstract method.

       10. What is an inner class?
             Answer :
Non static classes that are nested directly in another class
       11. What is the message protocol of an object?
             Answer : 
The message protocol of an objects are all the methods.
       12. From where are Smalltalk objects allocated?
             Answer : 
Smalltalk objects are allocated from the heap and are referenced through reference variables, which are implicitly dereferenced.
       13. Explain how smalltalk messages are bound to methods. When does this take place?
             Answer :
all computation is through message. Replies to messages have the form of objects and are used to return requested or computed information or only to confirm that the requested service has been computed

Concepts of Programming Languages Chapter 11


Concepts of Programming Languages Chapter 11


Name            : Erland
NIM              : 1601218035
Lecturer       : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment  : Concept of programming languages Chapter 11

Review Questions


       2.   Define abstract data types
             Answer :  
-The representation of objects of the type is hidden from the program units that use the type-The declarations of the type and the protocols of the operations on objects of the type
       3.   What are the advantages of the two parts of the definition of abstract data type
            Answer : 
-The program will increase reliability, reduce the range of code and number variables
-It provides a method of organizing a program into logical units that can be compiled separately.
       5.   What are the language design issues for abstract data types
             Answer :
-the form of the container for the interface to the type
-whether abstract data type can be parameterized
-what access controls are provided and how such controls are specified
-whether the specification of the type is physically separate from its implementation
       6. Explain how information hiding is provide in Ada package?
            Answer :
the designer can define a data type to choose and make the type entirely visible to clients or provide only the interface information.
       7. To what is the private part of an Ada package specification visible?
             Answer : 
To the compiler but not to the client programs
       8. What is the difference between private and limited private types in Ada?
           Answer : 
-Private types in Ada, it has built-in operations for assignment and comparisons for equality and inequality.
-Limited private types in Ada, are described in the private section of a package specification, as are non pointer private types. Limited private types are declared to be 

        9.  What is in an ada package specification? What about a body package?
             Answer:
A package specification and its associated body package share the same name. The reserved word body in a package header identifies it as being a body package. A package specification and its body package may be compiled separately.

        10.what is the use of Ada with clause?
              Answer : 
To make the names defined in external packages visible

       11. What is the use of Ada use clause?
             Answer :
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?
             Answer : 
C++ classes are types ; as stated previously, Ada packages are more generalized encapsulations that can define any number of types. Ada packages can access any of its public entities directly by their names. a C++ program unit that declares an instance of a class can also access all of the public entities in that class, but only through an instance of the class.
       13. From where are C++ objects allocated?
             Answer : 
from heap memory are C++ objects allocated 
       15. What is the purpose of a C++ destructor?
             Answer :
Destructor is 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 member are deallocated.

Concepts of Programming Languages Chapter 10


Concepts of Programming Languages Chapter 10


Name            : Erland
NIM              : 1601218035
Lecturer       : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment  : Concept of programming languages Chapter 10

Review Questions


       1.  What is the definition used in this chapter for simple subprogram?
             Answer : 
the subprograms cannot be nested and all local variables are statics.
       2. Which of the caller or callee saves execution status information?
            Answer : 
It can be done by both of em
       4. What is the task of a linker?
             Answer :
The task of a linker is to find the files that contain the translated subprograms referenced in that  and load them into memory
       5. What are the two reasons why implementing subprograms with stack-dynamic
            local variables 
             Answer :
the compiler must generate code to cause the implicit allocation and deal-location of local variables.recursion adds the possibility of multiple simultaneous activations of a subprogram
       6. What is the difference between the activation record and an activation
            record instance?
             Answer : 
activation record : the data it describes are relevant only during the activation, or the execution of the subprogram. 
Activation record instance: a concrete example of an activation record, a collection of data in the form of an activation record.
       7Why are the return address, dynamic link, and parameters placed in the 
           bottom of the activation record?
           Answer : 
It's because the entry must appear first.

        10. Define static chain, static_depth, nesting depth and chain_offset
             Answer:
-Static chain is a chain of static links that connect certain activation record instances in the stack-Static depth is an interger associated with a static scope that indicated how deeply it is nested  in the outermost scope.-Nesting depth is the length of the static chain needed to reach the correct activation record instance for a nonlocal reference to a variable -Chain_offset is the length of static depth of the subprogram containing the reference to and  declaration for X.


        11. What is an EP and what is its purpose?
              Answer : 
EP points at the base, or the first address of the activation record instanceof the main program. EP is used to access parameters and local variables during the execution of subprograms

       15. Explain the two methods of implementing blocks
             Answer :
– deep access– shallow access
       16. Describe the deep-access method of implementing dynamic scoping
             Answer : 
The dynamic chain links together all subprogram activation record instances in the reverse of the order in which they were activated. The dynamic chain is exactly what is needed to reference nonlocal variables in a dynamic-scoped language.

Concepts of Programming Languages Chapter 9


Concepts of Programming Languages Chapter 9


Name            : Erland
NIM              : 1601218035
Lecturer       : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment  : Concept of programming languages Chapter 9

Review Questions


       1.  What are the 3 general characteristics of subprograms?
             Answer : 
– each subprograms has a single entry end points – 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 return to the caller when the subprogram execution terminates
       2. What does it mean for a subprogram to be active?
            Answer : 
A subprogram is said to be active after having been called, it has begun execution but has not yet completed that execution
       3. What is given in the header of a subprogram?
             Answer :
The header is given a special words type
       6. What is ruby array formal parameter?
             Answer :
Ruby array formal parameter is the single parameter which followed by the hash item which preceded by an asterik. Ruby allows a variable number of parameters in a way similar to C# because ruby arrays can store different types.
       7. What is a parameter profile? What is subprogram protocol?
             Answer : 
Parameter profile of a subprogram contains the number, order, and types of its formsl parameter. A protocol of subprogam is ite parameter profile plus, if it is a function, its return type。
       8What are formal parameters? What are actual parameter?
           Answer : 
The parameters in the subprogram header are called formal parameters. Subprogram call statements must include the name of the subprogram and a list of parameters to be bound to the formal parameters of the subprogram. These parameters are called actual parameters.

        9. What are the advantages and disadvantages of the keyword parameter?
             Answer:
The advantage of keyword parameters is that they can appear in any order in the actual parameter list. The disadvantage to keyword parameters is that the user of the subprogram must know the names of formal parameters.?


        10.  What are the differences between a function and a procedure?
                Answer : 
a function returns value but procedures do not. Function are structurally resemble procedures but are semantically modeled on mathematical parameter.

       11. What are the design issues of a subprogram?
             Answer :
– are local variable statically or dynamically allocated? – can subprogram definitions appear in other subprogram definition? – what parameter-passing method or methods are used? – can subprogram overload? – can subprogram be generic? – if a language allow nested subprogram, are closures supported?


         12. What are the advantages and disadvantages of dynamic local variable?
             Answer : 
advantage: – they are bound to storage whdn the subprogram begins execution and are unbound from storage when that execution terminates – flexible – the storage for local variables in an active subprogram can be shared with the local variable in all inactive subprogram.

Disadvantage: – the cost of time required to allocate, initialize, and deallocate such variables for each call to the subprogram. – the access to stack-dynamically local variable must be indirect. – subprogram cannot be history sensitive.
         13. What are the advantages and disadvantages of static local variable?
                Answer : 
Advantage :
-more efficient
-they require no run-time overhead for allocation and deallocation.   
Disadvantages :
- inability to support recursion.
-storage cannot be shared with the local variables of other inactive subprograms.
14. What languages allow subprogram definition to be nested?
       Answer :
Algol 60, Algol 68, Pascal, Ada