Saturday, 6 June 2015

Kegiatan Bersih-Bersih 4 (Project TFI dan CB: Kewarganegaraan)

Nama: Billy
NIM: 1801374785
Hari/tanggal bersih-bersih: Kamis, 4 Juni 2015


                Ini adalah postingan terakhir saya untuk project TFI dan CB: Kewarganegaraan ini. Pada postingan ini saya akan menceritakan tentang kegiatan bersih-bersih yang saya dan kelompok saya lakukan pada hari keempat.
                Saya dan kelompok saya mendatangi kembali toko tempat kami bersih-bersih sebelumnya pada hari keempat ini. Toko yang kami bersihkan tampak sudah lebih memperhatikan kebersihan dibandingkan hari-hari kunjungan kami sebelumnya. Pada kesempatan ini, kami akan melakukan kegiatan bersih-bersih terakhir di toko ini dengan harapan toko ini bisa lebih memperhatikan kebersihan ke depannya.
                Kami pun kembali melakukan pembagian tugas seperti biasa pada hari keempat ini. Pada hari terakhir ini, saya mendapatkan tugas untuk menyapu bagian depan toko. Tugas ini bertujuan untuk membersihkan debu pada lantai depan toko. Saya menyapu toko dengan tidak melupakan pojokan-pojokan toko agar seluruh lantai toko dapat terlihat bersih. Setelah disapu
                Selesai membersihkan toko saya dan teman-teman saya melihat keadaan akhir toko dan menurut kami toko pun sudah kami bersihkan dengan baik. Hal ini berarti bahwa berakhirlah tugas kami untuk melakukan kegiatan kebersihan ini. Kami pun berpamitan dengan pegawai toko dan sekaligus mengucapkan terima kasih karena kelompok kami udah diizinkan untuk melakukan kegiatan bersih-bersih di toko mereka.

             

Kegiatan Bersih-Bersih 3 (Project TFI dan CB: Kewarganegaraan)

Nama: Billy
NIM: 1801374785
Hari/tanggal bersih-bersih: Rabu, 3 Juni 2015


                Pada postingan ini, saya mau memberikan laporan sekaligus menceritakan kegiatan bersih-bersih toko yang saya lakukan bersama kelompok saya di hari ketiga.
                Saya dan kelompok saya kembali mendatangi toko tempat di mana kami pernah melakukan kegiatan bersih-bersih sebelumnya. Seperti biasa, saya dan kelompok saya kembali melakukan pembagian tugas dengan tujuan untuk membuat pekerjaan yang akan dilakukan jadi terkoordinasi dengan baik. Pada hari ketiga ini, saya mendapatkan tugas yang berbeda dibandingkan hari pertama dan kedua, yakni saya bertugas untuk membersihkan begian depan toko. Saya membersihkan bagian dalam ruangan meja dan kursi walaupun memang terlihat bersih kami hanya ingin memastikan bahwa perawatan di toko ini di jalani dengan baik. Teman-teman saya yang lainnya pun melakukan tugasnya dengan baik, baik yang bertugas di dalam maupun di luar toko.
                Kondisi akhir toko pun terlihat jadi bersih kembali karena kegiatan yang kami lakukan ini. Sesudah kami selesai bertugas, kami pun melapor dengan pegawai toko dan kami pun pulang ke rumah kami masing-masing dengan perasaan senang.
                Di hari ketiga ini kami semakin menyadari akan pentingnya kebersihan di lingkungan sekitar kita. Kami pun berharap agar orang-orang khususnya pegawai toko dapat menjaga kebersihan lingkungan di sekitar kita.

Kegiatan Bersih-Bersih 2 (Project TFI dan CB: Kewarganegaraan)

Nama: Billy
NIM: 1801374785
Hari/tanggal bersih-bersih: Senin, 1 Juni 2015

Pada postingan kali ini saya mau memberikan laporan mengenai kegiatan yang saya lakukan bersama kelompok saya dalam membersihkan toko pada hari kedua.
                Pada hari kedua ini kami kembali melakukan kegiatan bersih-bersih seperti yang telah kami rencanakan. Kami mendatangi toko yang ingin kami bersihkan lalu kami pun mulai melakukan kegiatan bersih-bersih. Pada awal kami datang, toko nampak tidak terlalu bersih, hal ini dapat dilihat dari kondisi luar dan dalam toko.
                Saya dan teman-teman saya kembali sepakat untuk melakukan pembagian tugas di hari kedua bersih-bersih ini. Hal ini dilakukan dalam rangka untuk meringankan pekerjaan yang kami lakukan dan juga agar pekerjaan yang mau dilakukan dapat terkoordinasi dengan baik. Saya pun kembali mendapatkan tugas untuk melakukan pembersihan pada pintu depan toko dengan cara membersihkannya dengan lap dan cairan pembersih kaca  yang sudah saya dan kelompok saya persiapkan sebelumnya. Pekerjaan dilakukan dengan seksama agar hasilnya bisa terlihat maksimal. Teman saya yang lainnya pun melakukan tugasnya masing-masing. Pada hari ini saya membantu membersihakan kaca depan yang nampak sedikit agak kotor.
                Selesai kami membersihkan toko, kami pun mengamati apabila masih ada hal yang terlewati saat kami melakukan kegiatan bersih-bersih. Setelah melihat hasil kerja kami, kami pun sepakat bahwa tidak ada hal yang terlewatkan dilihat dari kondisi toko yang bersih setelah dibersihkan. Kami pun mengakhiri kegiatan bersih-bersih ini.
                Dari hari kedua ini saya dan kelompok saya kembali belajar bahwa kebersihan adalah suatu hal yang tidak bisa dipandang sebelah mata. Oleh karena itu, kami pun akan selalu berusaha untuk menjaga kebersihan di lingkungan sekitar kami dengan semaksimal mungkin agar orang lain bisa ikut tergerak juga untuk menjaga lingkungan di sekitar kita.

Kegiatan Bersih-Bersih Hari -1 (Project TFI dan CB: Kewarganegaraan)

Nama: Billy
NIM: 1801374785
Hari/tanggal bersih-bersih: Jumat, 29 Mei 2015

               Pada kesempatan ini saya mau memberikan laporan terkait kegiatan yang saya lakukan bersama kelompok saya untuk project TFI dari mata kuliah Character Building: Civics (Kewarganegaraan). Project ini dilakukan untuk menyadarkan orang-orang bahwa kebersihan adalah suatu hal yang sangat penting.
            Pada awal kami melakukan kegiatan bersih-bersih terlihat toko yang kami datangi sebagai tempat untuk melakukan kegiatan bersih-bersih tampak tidak terlalu bersih terutama dilihat dari kondisi pintu depan dan lantai toko. Namun saya dan kelompok saya  untuk membersihkannya.
            Saya dan kelompok saya pun mulai melakukan kegiatan bersih-bersih. Kami membagi tugas agar kegiatan yang dilakukan bisa menjadi lebih ringan. Saya mendapatkan tugas untuk membersihkan kaca pada pintu depan. Saya membersihkannya dengan menggunakan lap dan cairan pembersih kaca yang sudah kami persiapkan. Saya pun mendapatkan bantuan dari teman saya yang juga bertugas membersihkan kaca. Setiap individu yang ada melakukan tugasnya dengan baik sehingga kegiatan bersih-bersih pada hari pertama pun dapat kami selesaikan dengan baik.
            Kondisi akhir dari toko yang kami bersihkan tampak lebih baik dan bersih dibandingkan saat kami belum membersihkan toko tersebut. Kami pun bisa pulang dengan perasaan senang karena bisa membantu toko tersebut dan telah menyelesaikan tugas dengan baik.
            Dari hari pertama ini kami belajar bahwa kebersihan adalah suatu hal yang sangat penting untuk kita jaga. Kami pun berharap dari sini bahwa masyarakat bisa terus menjaga kebersihan lingkungan sekitarnya agar kita bisa menjadi masyarakat yang lebih maju dengan penghargaan atas kebersihan ini.


Saturday, 10 January 2015

Chapter 10

Chapter 10

Name : Billy
NIM   :1801374785

Kali ini saya akan menjawab Assignment #10 dari Chapter 10 Programming Language Concepts R Sebesta

Review Questions

6. What is the difference between an activation record and an activation record instance?
*An activation record is the format, or layout, of the moncode part of a subprogram. An activation record instance is a concrete example of an activation record, a collection of data in the form of an activation record.

7. Why are the return address, dynamic link, and parameters placed in the bottom of the activation record?
*It's because the entry must appear first.

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

9. What are the two steps in locating a nonlocal variable in a static-scoped language with stack-dynamic local variables and nested subprograms?
*First step, find correct activation record (the harder part) and then the second step is determine the offset within that activation record (easy part).

10. Define static chain, static_depth, nesting_depth, and chain_offset.
*Static chain is chain of static links connecting an activation record to all of it's static ancestors (it's enclosing subprograms).
Static depth is depth of the nesting for each enclosing static scope.
Nesting depth is the difference between the static depth of the reference and that of the scope where it was declared.
Chain offset is same as nesting depth.


Problem Set

6. Although local variables in Java methods are dynamically allocated at the beginning of each activation, under what circumstances could the value of a local variable in a particular activation retain the value of the previous activation?
*Each activation allocates variables in exactly the same order. Variables are not initialized to any value unless the program contains an initialization statement for the variable – they simply have whatever value is stored in the location they are allocated. If a procedure finishes executing, returns, and is immediately reinvoked, a variable would be assigned the same stack location it had on the previous invocation, and would have the last value from that previous invocation.

7. It is stated in this chapter that when nonlocal variables are accessed in a dynamic-scoped language using the dynamic chain, variable names must be stored in the activation records with the values. If this were actually done, every nonlocal access would require a sequence of costly string comparisons on names. Design an alternative to these string comparisons that would be faster.
*Using approach that uses an auxiliary data structure called a display. Or, to write variable names as integers. These integers act like an array. So when the activation happens, the comparisons will be faster.

8. Pascal allows gotos with nonlocal targets. How could such statements be handled if static chains were used for nonlocal variable access? Hint: Consider the way the correct activation record instance of the static parent of a newly enacted procedure is found (see Section 10.4.2).
*Based on the hint statement, the target of every goto in a program could be represented as an address and a nesting depth, where the nesting depth is the difference between the nesting level of the procedure that contains the goto and that of the procedure containing the target. Then, when a goto is executed, the static chain is followed by the number of links indicated in the nesting depth of the goto target. The stack top pointer is reset to the top of the activation record at the end of the chain.

9. The static-chain method could be expanded slightly by using two static links in each activation record instance where the second points to the static grandparent activation record instance. How would this approach affect the time required for subprogram linkage and nonlocal references?
*Including two static links would reduce the access time to nonlocals that are defined in scopes two steps away to be equal to that for nonlocals that are one step away. Overall, because most nonlocal references are relatively close, this could significantly increase the execution efficiency of many programs.

10. Design a skeletal program and a calling sequence that results in an activation record instance in which the static and dynamic links point to different activation-recorded instances in the run-time stack.
*\\
\emph{Answer}:\\
procedure Main\_2 is\\
\verb+    + X : Integer;\\
\verb+    +procedure Bigsub is\\
\verb+    +\verb+    +    A, B, C : Integer;\\
\verb+    +\verb+    +    procedure Sub1 is\\
\verb+    +\verb+    +\verb+    +    A, D : Integer;\\
\verb+    +\verb+    +\verb+    +    begin -- of Sub1\\
\verb+    +\verb+    +\verb+    +    A := B + C; $\longleftarrow$ 1\\
\verb+    +\verb+    +\verb+    +      ...\\
\verb+    +    end; -- of Sub1\\
\verb+    +    procedure Sub2(X : Integer) is\\
\verb+    +\verb+    +      B, E : Integer;\\
\verb+    +\verb+    +      procedure Sub3 is\\
\verb+    +\verb+    +\verb+    +        C, E : Integer;\\
\verb+    +\verb+    +\verb+    +        begin -- of Sub3\\
\verb+    +\verb+    +\verb+    +        ...\\
\verb+    +\verb+    +\verb+    +        Sub1;\\
\verb+    +\verb+    +\verb+    +        ...\\
\verb+    +\verb+    +\verb+    +        E := B + A; $\longleftarrow$ 2\\
\verb+    +\verb+    +      end; -- of Sub3\\
\verb+    +\verb+    +      begin -- of Sub2\\
\verb+    +\verb+    +      ...\\
\verb+    +\verb+    +      Sub3;\\
\verb+    +\verb+    +      ...\\
\verb+    +\verb+    +      A := D + E; $\longleftarrow$ 3\\
\verb+    +    end; -- of Sub2\\
\verb+    +    begin -- of Bigsub\\
\verb+    +\verb+    +    ...\\
\verb+    +\verb+    +    Sub2(7);\\
\verb+    +\verb+    +    ...\\
\verb+    +  end; -- of Bigsub\\
  begin -- of Main\_2\\
\verb+    +  ...\\
\verb+    +  Bigsub;\\
\verb+    +  ...\\
end; -- of Main\_2\\
\\
The sequence of procedure calls is:\\
Main\_2 calls Bigsub\\
Bigsub calls Sub2\\
Sub2 calls Sub3\\
Sub3 calls Sub1\\
\\
The activation records with static and dynamic links is as follows:\\
\begin{figure}
\centering
\includegraphics[scale=0.5]{ari}
\end{figure}

At position 1 in procedure Sub1, the reference is to the local variable,
A, not to the nonlocal variable A from Bigsub. This reference to A has the
chain\_offset/local\_offset pair (0, 3). The reference to B is to the nonlocal B
from Bigsub. It can be represented by the pair (1, 4). The local\_offset is 4,
because a 3 offset would be the first local variable (Bigsub has no parameters). Notice that if the dynamic link were used to do a simple search for
an activation record instance with a declaration for the variable B, it would
find the variable B declared in Sub2, which would be incorrect. If the (1, 4)
pair were used with the dynamic chain, the variable E from Sub3 would be
used. The static link, however, points to the activation record for Bigsub,
which has the correct version of B . The variable B in Sub2 is not in the
referencing environment at this point and is (correctly) not accessible. The
reference to C at point 1 is to the C defined in Bigsub, which is represented
by the pair (1, 5).\\
\\
\noindent

chapter 9

Chapter 9

Name : Billy
NIM   :1801374785

Kali ini saya akan menjawab Assignment #9 dari Chapter 9 Programming Language Concepts R Sebesta


Review Questions

6. What is a Ruby array formal parameter?
*Ruby supports a complicated but highly flexible actual parameter configuration. The initial parameters are expressions, whose value objects are passed to the corresponding formal parameters. The initial parameters can be following by a list of key => value pairs, which are placed in an anonymous hash and a reference to that hash is passed to the next formal parameter. These are used as a substitute for keyword parameters, which Ruby does not support. The hash item can be followed by a single parameter preceded by an asterisk. This parameter is called the array formal parameter.

7. What is a parameter profile? What is a subprogram protocol?
*Parameter profile is the number, order, and types of its formal parameters.
Subprogram protocol is its parameter profile plus, if it is a function, its return type. In languages in which subprograms have types, those types are defined by the subprogram’s protocol.

8. What are formal parameters? What are actual parameters?
*Formal parameters are the parameters in the subprogram header.
Actual parameters are a list of parameters to be bound to the formal parameters of the subprogram which must be included with the name of the subprogram by the subprogram call statements.

9. What are the advantages and disadvantages of keyword parameters?
*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?
*A function returns value but procedures do not. Function are structurally resemble procedures but are semantically modeled on mathematical parameter.


Problem Set

6. Present one argument against providing both static and dynamic local variables in subprograms.
*In subprograms local variables can be static or dynamic;
If local variable treated statically:
This allows for compile-time allocation/ deallocation and ensures proper type checking but does not allow for recursion.
And if local variables treated dynamically:
This allows for recursion at the cost of run-time allocation/ deallocation and initialization because these are stored on a stack, referencing is indirect based on stack position and possibly time-consuming.


7. Consider the following program written in C syntax:
void fun (int first, int second) { 
first += first;
second += second;
}
void main() { 
int list[2] = {1, 3}; 
fun(list[0], list[1]);
}
For each of the following parameter-passing methods, what are the values of the list array after execution?
a. Passed by value                       : 1,3
b. Passed by reference                 : 2,6
c. Passed by value-result             : 2,6

8. Argue against the C design of providing only function subprograms.
*If a language provides only functions, then either programmers must live with the restriction of returning only a single result from any subprogram, or functions must allow side effects, which is generally considered bad. Since having subprograms that can only modify a single value is too restrictive, C’s choice is not good.

9. From a textbook on Fortran, learn the syntax and semantics of statement functions. Justify their existence in Fortran.
* The Fortran 1966 standard provided a reference syntax and semantics, but vendors continued to provide incompatible extensions. These standards have improved portability.

10. Study the methods of user-defined operator overloading in C++ and Ada, and write a report comparing the two using our criteria for evaluating languages.
* One of the nice features of C++ is that you can give special meanings to operators, when they are used with user-defined classes. This is called operator overloading. You can implement C++ operator overloads by providing special member-functions on your classes that follow a particular naming convention. For example, to overload the + operator for your class, you would provide a member-function named operator+ on your class.
Meanwhile for Ada, since much of the power of the language comes from its extensibility, and since proper use of that extensibility requires that we make as little distinction as possible between predefined and user-defined types, it is natural that Ada also permits new operations to be defined, by declaring new overloadings of the operator symbols.

Sunday, 7 December 2014

chapter 8

Name: Billy
NIM: 1801374785

Kali ini saya akan menjawab Assignment #8 dari Chapter 8 Programming Language Concepts R Sebesta


Review Questions

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.

8. What are the common solutions to the nesting problem for two-way selectors?
*The common solution is to force an alternative semantics, by using compound statements.

9. What are the design issues for multiple-selection statements?
*-What is the form and type of the control statement?
-How are the selectable segments specified?
-Is execution flow through the structure restricted to include just a single selectable segment?
-How are case values specified?
-What is done about unrepresented expression values?

10. Between what two language characteristics is a trade-off made when deciding whether more than one selectable segment is executed in one execution of a multiple selection statement?
*In Ada, the choice lists of the case statement must be exhaustive, so that there can be no unrepresented values in the control expression. In C++, unrepresented values can be caught at run time with the default selector. If there is no default, an unrepresented value causes the whole statement to be skipped.


Problem Set

6. Analyze the potential readability problems with using closure reserved words for control statements that are the reverse of the corresponding initial reserved words, such as the case-esac reserved words of ALGOL 68. For example, consider common typing errors such as transposing characters.
*The potential readability problem is the typing errors. It’s very possible to occur if we don’t type the code carefully.

7. Use the Science Citation Index to find an article that refers to Knuth (1974). Read the article and Knuth’s paper and write a paper that summarizes both sides of the goto issue.
*An alternative viewpoint is presented in Donald Knuth's Structured Programming with go to Statements, which analyzes many common programming tasks and finds that in some of them GOTO is the optimal language construct to use.[7] In their quasi-standard book on the C programming language, Dennis Ritchie and Brian Kernighan warn that goto is "infinitely abusable", but also suggest that it could be used for end-of-function error handlers and for multi-level breaks from loops.

8. In his paper on the goto issue, Knuth (1974) suggests a loop control statement that allows multiple exits. Read the paper and write an operational semantics description of the statement.
*Operational semantics are a category of formal programming language semantics in which certain desired properties of a program, such as correctness, safety or security, are verified by constructing proofs from logical statements about its execution and procedures, rather than by attaching mathematical meanings to its terms (denotational semantics).

9. What are the arguments both for and against the exclusive use of Boolean expressions in the control statements in Java (as opposed to also allowing arithmetic expressions, as in C++)?
*The primary argument for using Boolean expressions exclusively as control expressions is the reliability that results from disallowing a wide range of types for this use. In C, for example, an expression of any type can appear as a control expression, so typing errors that result in references to variables of incorrect types are not detected by the compiler as errors. No , it would not be a good idea. Although this custom precedence sounds like increasing flexibility, requiring parentheses to show a custom precedence would impact in readability and writability of a program.

10. In Ada, the choice lists of the case statement must be exhaustive, so that there can be no unrepresented values in the control expression. In C++, unrepresented values can be caught at run time with the default selector. If there is no default, an unrepresented value causes the whole statement to be skipped. What are the pros and cons of these two designs (Ada and C++)?
*Ada was designed for military grade software development. The idea is that whenever you modify code in such a way that a new case emerges (for example adding a new value for an enumeration type), you are forced to manually revisit (and therefore re-validate) all the case statements that analyze it. Having a "default" is risky: you may forget that there is a case somewhere where the new case should not have been handled by the default.