tag:blogger.com,1999:blog-45642970486399474752024-02-13T15:29:34.843+07:00Ryan Dratama's BlogAnonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.comBlogger21125tag:blogger.com,1999:blog-4564297048639947475.post-53817417767027061932016-04-07T20:03:00.000+07:002016-04-07T20:03:25.838+07:00Hi Again, After 3 YearsHello guys, well, it's been a long time since my last post, and when I read it again it's like, LOL. I have said that I want to give some effort to keep this blog alive, but.... It IS already 3 years. so maybe you guys need to wait some time more longer for the next post ! XD. But now, I'm renewing my motivation. I need to write, because I want to share something, and to improving myself. Nowadays I spend a lot of time to play a game, an online game, and it takes a lot of time. And, I have been thinking, I need to include some time to improve myself more.<br />
<br />
I need to go back reading again.<br />
Yeah, reading, I used to love reading, when I have the money and go to a bookstore, each book like "BUY ME !, BUY ME !, YOU WILL REGRET IT IF YOU DONT BUY ME!" Aaaaaaanndd, I'm planning to buy just one book, and somehow I have 3 books by I reach the cashier.<br />
That's just one simple example how I love books so much.<br />
One time I was reading Eragon series (It's really good, if you like fiction) I do not realize, I haven't change my position for 6 hours straight, and you guess what ? My body scream in pain after I finished reading.<br />
<br />
Now, so much time have passed, not only what I do is changing, now my occupation also changing.<br />
Before I am an university student. Now I am already a fresh graduate seeking for job (unemployed for the moment). There are so much thing, that become a dilemma for me, having nothing to do means I have a lot of free time, but not so productive, but when I come for a job interview, it's like, I'm afraid losing my freedom.<br />
<br />
Well, that's enough for now, I will continue this blog eventually, and I will learn much more thing.<br />
See ya. :)Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-44767501330340583872013-11-07T09:48:00.004+07:002013-11-07T09:56:02.850+07:00My Second FamilyNah, kenapa sih judulnya itu "My Second Family", kenapa saya tidak tulis, My Family, apa sih maksud dari keluarga kedua itu ? Kalo menurut saya, keluarga kedua itu adalah sebuat komunitas dimana saya diterima dan diakui di dalam komunitas ini, puji Tuhan saya punya sebuah komunitas yang luar biasa yang memberkati saya setiap minggunya.<br />
<br />
Komunitas itu bernama PD OMPKK St. Alfonsus ( Persekutuan Doa Orang Muda Pembaharuan Katolik Karismatik St. Alfonsus Rodriguez), nama yang cukup panjang, tetapi tidak masalah karena saya bukan mau menjelaskan tentang nama dari komunitas itu ataupun promosi, disini saya ingin membagikan sebuah <i>sharing</i> dari seorang yang kami undang pada acara persekutuan doa kami, dan <i>sharing</i> itu tentang komunitas, dan terutama komunitas kristiani, bagaimana sebuah komunitas dapat memberkati kita setiap minggunya, kita dapat merasa diterima, dan juga tentuka kita mendapatkan banyak teman.<br />
<br />
Sharing ini berasal dari ko Cello, nah di sini saya akan memberi rekaman, kalian dapat mendengarkan sendiri apa aja sih intinya komunitas itu, dan juga ada ringkasan singkat yang saya buat sendiri dari pengajaran ko cello<br />
<br />
http://www.4shared.com/mp3/5hVvDnhH/my_second_family_by_ko_cello.html<br />
ini file rekamannya<br />
<br />
Berdasarkan dari hukum kasih.<br />
Kita tidak bisa mencintai orang lain, jika kita belum mencintai diri kita sendiri.<br />
Bagaimana ? Kita harus mencintai Allah. Kita harus mengerti isi hati Tuhan<br />
Jika kita mengerti isi hati Allah, maka sesuai kitab kejadian kita "serupa" dengan Allah,<br />
jika kita tidak mengerti karakter dari Allah kita tak bisa mencintai sesama<br />
<br />
Bagaimana orang berteman, kalau tidak mengikuti ajaran Yesus kalau sekali disakiti, tidak mau<br />
mengampuni.<br />
Kita harus belajar akan hal ini, agar ketika setiap kita masuk ke keluarga kita, dimanapun<br />
biar menjadi mulus.<br />
<br />
Apa yang spesial dari keluarga ?<br />
Apa yang membuat kita mau mengambil bagian dari sebuah keluarga ?<br />
Keluarga merupakan institusi paling tua dan berasal dari Tuhan.<br />
Apa yang membuat keluarga kedua menjadi penting bagi kita juga ?<br />
<br />
F A M I L Y :<br />
F = Faith<br />
[inti dari komunitas Kristiani, dimana kita belajar dari Firman, Doa, dan Sahabat kita]<br />
Komunitas merupakan tempat kita dibentuk oleh Tuhan.<br />
Belajar tentang Yesus melalui orang" di sekitar kita<br />
<br />
A = Acceptance<br />
[bagaimana kita diterima melalui komunitas]<br />
Kita semua orang berdosa, tidak ada yang sempurna, kita harus menanamkan bahwa,<br />
Allah menciptakan kita dengan berbagai keunikan, berbagai bakat, talenta, karunia<br />
tetapi dari semua ras, golongan, latar belakang, disini kita belajar untuk belajar saling menerima<br />
Dimana kita saling mensupport, mendoakan, meneguhkan.<br />
<br />
M = Maturity<br />
[Untuk bergabung dengan komunitas Kristiani diperlukan kedewasaan]<br />
Orang Dewasa = orang yang sanggup merespon segala sesuatu dengan ajaran/firman Tuhan<br />
Kedewasaaan untuk mengampuni, bersikap sesuai ajaran Yesus<br />
Orang yang bisa mengampuni = orang yang dewasa<br />
<br />
I = Intimacy<br />
[bagaimana kita belajar mengenal saudara seiman kita di dalam komunitas]<br />
bagaimana kita bisa menolong, mensupport jika kita tak mengenal dengan baik saudara kita<br />
hubungan yang dekat didapat dari komunikasi yang baik<br />
Jangan cuma mau deket ama beberapa orang tertentu, kalau begini bisa terjadi perpecahan<br />
Jangan biarkan status sosial menjadi kendala<br />
<br />
"We cannot giving without loving, and loving without giving"<br />
<br />
L = Laugh<br />
[We need time to have fun together too, but in the way of God]<br />
kita butuh untuk fellowship dengan satu sama lain<br />
Bagaimana kita membagikan sukacita dengan yang lain<br />
<br />
Y = You<br />
Kita [Karena kitalah yang Tuhan panggil untuk melakukan semua itu]<br />
setiap individu dipanggil untuk yang lain<br />
<br />
<br />
<br />
<br />
<br />
Dan juga terutama karena <br />
Pembaharuan Karismatik Katolik membahas bagaimana kita diperbaharui dengan Roh Allah sehingga kita memancarkan karunia - karunia[karisma] dari Roh Kudus. Dan karunia yang terbesar adalah Kasih.<br />
<br />
because we are a Family in God<br />
<br />
"True friend, Good Friendship, Make the Future"Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-35535619049537609182013-11-07T09:14:00.001+07:002016-04-07T19:53:10.832+07:00Hi :)It's already a long time ago since I last posted, actually this blog purpose was to fulfill my university assignment, but now I think, I need to use this blog for something more good, since it already here, I already made it, why I doesn't use it for a better purpose ?<br />
<br />
So now i reach my conclusion, I need to do something with this blog, I want to reach a higher level, and now I want to post more, more mystery, and I want to fulfill one more thing, I want to share what I believe all this time, I want to share what I get every week, as a young catholic guy, I want to share my passion about Jesus Christ with more people, so more people get Blessed too !<br />
<br />
I don't know I would post regularly or not, but I will keep my best to share what I get, more and more<br />
thanks for visiting, don't forget to visit next time, because more article would fill up this blog.<br />
<br />
God Bless.Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-64574859678573266822013-06-28T11:36:00.004+07:002013-06-28T11:36:31.135+07:00Chapter 16 of Concept of Programming Languages<span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong>Review Questions : </strong></span></span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">2.What are the two parts of a compound term?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"></span><span style="color: blue;"> </span>A compound term is composed of two parts, a functor and an ordered list of parameter</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">5. What are the antecedents? Consequent?</span><span style="color: blue;"></span></span></span>
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"></span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>The right side of a clausal form proposition is called the antecendent.
The left side is called the consequent because it is the consequence of
the truth antecendent</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">7. What are the forms of Horn clauses?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Horn clauses can be in only two forms: they have either a single atomic proposition on the left side or an empty left side.</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">8. What is the basis concept of declarative semantics?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>The basic concept of this semantics is that there is a simple way to
determine the meaning of each statement, and it does not depend on how
the statement might be used to solve a problem</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">10. What are the three forms of a Prolog term?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>A prolog term is a constant, a variable, or a structure</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">11. What is an uninstantiated variable?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong> </strong></span>A variable that has not been assigned a value is called uninstantiated</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong> </strong></span></span></span><br />
<span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong>Problem Set :</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">1. ”All predicate calculus propositions can be algorithmically
converted to clausal form”. Is this </span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">statement true or false? Explain</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>The statement is true. this was proven by Nilsson (1971) by using a simple conversion algorithm</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">2. Describe how a logic programming language is different from a general programming language</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span> Logical programming language uses a form of symbolic logic, the
syntax of logic programming logic is remarkably different from that of
the imperative and functional languages.</span></span>
<br />
Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com4tag:blogger.com,1999:blog-4564297048639947475.post-80341502754041584652013-06-28T11:31:00.002+07:002013-06-28T11:31:15.932+07:00Chapter 15 of Concept of Programming Languages<span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong>Review Questions</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><strong></strong><br /><span style="color: blue;"><strong>2. What does a lambda expression specify?</strong></span><br />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.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>5. Explain why QUOTE is needed for a parameter that is a data list.</strong></span><br />To
avoid evaluating a parameter, it is first given as a parameter to the
primitive function QUOTE, which simply returns it without change.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>6. What is a simple list?</strong></span><br />A list which membership of a given atom in a given list that does not include sublists.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>7. What does the abbreviation REPL stand for?</strong></span><br />REPL stand for read-evaluate-print loop.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>11. What are the two forms of DEFINE?</strong></span><br />The simplest form of DEFINE is one used to bind a name to the value of an expression. This form is<br />(DEFINE symbol expression)<br />The general form of such a DEFINE is<br />(DEFINE (function_name parameters)<br />(expression)<br />)</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>13. Why are CAR and CDR so named?</strong></span><br />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<br />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<br />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.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>18. What is tail recursion? Why is it important to define
functions that use recursion to specify repetition to be tail recursive?</strong></span><br />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).</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>19. Why were imperative features added to most dialects of LISP?</strong></span><br />LISP
began as a pure functional language but soon acquired some important
imperative features to increased its execution efficiency.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>26. What is type inferencing, as used in ML?</strong></span><br />Type
inference refers to the automatic deduction of the type of an
expression in a programming language. If some, but not all, type
annotations are already present it is referred to as type
reconstruction.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>29. What is a curried function?</strong></span><br />Curried functions a function which a new functions can be constructed from them by partial evaluation.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>30. What does partial evaluation mean?</strong></span><br />Partial
evaluation means that the function is evaluated with actual parameters
for one or more of the leftmost formal parameters.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>32. What is the use of the evaluation environment table?</strong></span><br />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.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>33. Explain the process of currying.</strong></span><br />The process
of currying replaces a function with more than one parameter with a
function with one parameter that returns a function that takes the other
parameters of the initial function.</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">_______________________________________________________________________________________________________________________________ </span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong>Proble</strong><strong>m Set</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>2 . Give a general form of function declaration in ML.</strong></span><br />Function declarations in ML appear in the general form<br />fun function_name(formal parameters) = expression;</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>4. Refer to a book on Haskell programming and discuss the features of Haskell.</strong></span><br />Haskell features lazy evaluation, pattern matching, list comprehension, type classes, and type polymorphism.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>8. How is the functional operator pipeline (|>) used in F#?</strong></span><br />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.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>9. What does the following Scheme function do?</strong></span><br /><span style="color: blue;">(define (y s lis)<br />(cond<br />((null? lis) ‘() )<br />((equal? s (car lis)) lis)<br />(else (y s (cdr lis)))<br />))</span><br />y
returns the given list with leading elements removed up to but not
including the first occurrence of the first given parameter.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>10. What does the following Scheme function do?</strong></span><br /><span style="color: blue;">(define (x lis)<br />(cond<br />((null? lis) 0)<br />((not (list? (car lis)))<br />(cond<br />((eq? (car lis) #f) (x (cdr lis)))<br />(else (+ 1 (x (cdr lis))))))<br />(else (+ (x (car lis)) (x (cdr lis))))</span><br />x returns the number of non-NIL atoms in the given list.</span></span>Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-60202954091185917262013-06-28T11:25:00.005+07:002013-06-28T11:25:32.424+07:00Chapter 14 of Concept of Programming Languages<span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong>Review Question</strong></span></span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>6 . What is exception propagation in Ada?</strong></span><br />
Exception propagation allows an exception raised in one program unit to
be handled in some other unit in its dynamic or static ancestry. This
allows a single exception handler to be used for any number of different
program units. This reuse can result in significant savings in
development cost, program size, and program complexity.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>9. What is the scope of exception handlers in Ada?</strong></span><br />
Exception handlers can be included in blocks or in the bodies of subprograms, packages, or tasks.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>10. What are the four exceptions defined in the Standard package of Ada?</strong></span><br />
There are four exceptions that are defined in the default package, Standard:</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><pre><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Constraint_aError
Program_Error
Storage_Error
Tasking_Error</span></span></pre>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>11. are they any predefined exceptions in Ada?</strong></span><br />
Yes, they are.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>12. What is the use of Suppress pragma in Ada?</strong></span><br />
The suppress pragma is used to disable certain run-time checks that<br />
are parts of the built-in exceptions in Ada.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>14. What is the name of all C++ exception handlers?</strong></span><br />
Try clause.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>15. Which standard libraries define and throw the exception <em>out_of_range</em>in C++?</strong></span><br />
Library container classes.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>16. Which standard libraries define and throw the exception <em>overflow_error</em>in C++?</strong></span><br />
Math library functions.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>25. What is the difference between checked and unchecked exceptions in Java?</strong></span><br />
Exceptions of class Error and <em>RuntimeException</em> and their
descendants are called unchecked exceptions. All other exceptions are
called checked exceptions. Unchecked exceptions are never a concern of
the compiler.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>30. In which version were assertions added to Java?</strong></span><br />
Assertions were added to Java in version 1.4.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>31. What is the use of the assert statement?</strong></span><br />
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.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>32. What is event-driven programming?</strong></span><br />
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.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>33. What is the purpose of a Java JFrame?</strong></span><br />
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.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>34. What are the different forms of assert statement?</strong></span><br />
There are two possible forms of the assert statement:<br />
assert condition;<br />
assert condition : expression;</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><hr />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><strong><span style="color: red;">Problem Set</span></strong></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>1 . What mechanism did early programming languages provide to detect or attempt to deal with errors?</strong></span><br />
Early programming languages were designed and implemented in such a way that the user program<br />
could neither detect nor attempt to deal with such errors. In these
languages, the occurrence of such an error simply causes the program to
be terminated and control to be transferred to the operating system. The
typical operating system reaction to a run-time error is to display a
diagnostic message, which may be meaningful and therefore useful, or
highly cryptic. After displaying the message, the program is terminated.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>2. Describe the approach for the detection of subscript range errors used in C and Java.</strong></span><br />
Java compilers usually generate code to check the correctness of every
subscript expression (they do not generate such code when it can be
determined at compile time that a subscript expression cannot have an
out-of-range value, for example, if the subscript is a literal).<br />
In C, subscript ranges are not checked because the cost of such checking
was (and still is) not believed to be worth the benefit of detecting
such errors. In some compilers for some languages, subscript range
checking can be selected (if not turned on by default) or turned off (if
it is on by default) as desired in the program or in the command that
executes the compiler.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>5. From a textbook on FORTRAN, determine how exception handling is done in FORTRAN programs.</strong><br />
<span style="color: black;">For example, </span></span>a Fortran “Read” statement can intercept inputerrors and
end-of-file conditions, both of which are detected by the input device
hardware. In both cases, the Read statement can specify the label of
some statement in the user program that deals with the condition. In the
case of the end-of-file, it is clear that the condition is not always
considered an error. In most cases, it is nothing more than a signal
that one kind of processing is completed and another kind must begin. In
spite of the obvious difference between end-of-file and events that are
always errors, such as a failed input process, Fortran handles both
situations with the same mechanism.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>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?</strong></span><br />
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.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>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?</strong></span><br />
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.</span></span>Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-4205103993702510862013-06-28T11:19:00.001+07:002013-06-28T11:19:14.405+07:00Chapter 13 of Concept of Programming Languages<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong><span style="font-size: x-large;">Review Questions :</span> </strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">7. What is the difference between physical and logical concurrency?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Several program units from the same program executes simultaneously,
this is called physical concurrency, while logical concurrency the
actual execution of program is taking place in interlaved fashion on a
single processor</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">8. What is the work of a scheduler?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>A scheduler manages the sharing of processors among the tasks.</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">9. Give some examples of languages which can be used for synchronization</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Ada, Java, C#, F#, Python</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">10. When a task in a blocked state?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>A task that is blocked has been running, but that execution was
interrupted by one of several different events, the most common of which
is an input or output operation.</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">18. What is the purpose of a task-ready queue?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span> a ready task is ready to run but is not currently running, either it
has not been given processor time by the scheduler, or it had run
previously but was blocked</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">19. What are the two primary design issues for language support for concurrency?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Competition and cooperation synchronization</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">20. Describe the actions of the wait and release operations for semaphores</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>The wait semaphore subprogram is used to test the counter of a given
semaphore variable. The release semaphore subprogram is used by a task
to allow some other task to have one of whatever the counter of the
specified semaphore variable counts</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">34. What does the Java sleep method do?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Sleep method specify the number of milliseconds the thread want to be
blocked and block the thread for that amount of milliseconds</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">35. What does the Java yield method do?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Join method is used to force a method to delay its execution until the run method of another thread has completed its execution</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">36. What does the Java join method do?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span> The join method puts the thread that calls it in the blocked state,
which can be ended only by the completion of the thread on which join
was called.</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">37. What does the Java interrupt method do?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>The interrupt method is one way to communicate to a thread that it should stop</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">48. What kind of methods can run in a C# threads?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Any C# method can run in its own thread</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">49. Can C# threads be actor threads, server threads, or either?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>C# support both actor and server threads.</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">55. What is Concurrent ML?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Concurrent ML is an extension to ML that includes a form of threads and a
form of synchronous message passing to support concurrency</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">56. What is the use of spawn primitive of CML?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong> </strong></span>Creating a thread in CML</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong>____________________________________________________________________________________________________________________________________ </strong></span></span></span><br />
<br />
<span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong>Problem Set :</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">2. What are the different ways to handle deadlock?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Deadlock handling :</span></span>
<br />
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Ignoring deadlock</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Detection : Process Terimnation and Resource preemption</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Prevention : preventing one of the four Coffman conitions from occuring</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Avoidance</span></span></li>
</ul>
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">3. Busy waiting is a method whereby a task waits for a given event by
continuously checking for that </span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> event to occur. What is the main problem
with this approach?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">The main problem would be the CPU resources that area allocated to
the waiting for the task, if it were to be suspended, the CPU can then
be used for other purposes</span></span>
<br />
Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-54178223200152813702013-06-28T11:13:00.001+07:002013-06-28T11:13:17.280+07:00Chapter 12 of Concept of Programming Languages<span style="font-size: x-large;"><span style="color: red;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>Review Question</b></span></span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>2. What are the problems associated with programming using abstract data types?</b></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">In nearly all cases, the features and capabilities of the existing type are not quite right for the new use.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">The type definitions are all independent and are at the same level.</span></span></li>
</ul>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>4. What is message protocol?</b></span><br />
The entire collection of methods of an object is called the message protocol, or message interface, of the object.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>5. What is an overriding method?</b></span><br />
An overriding method is a method that provide an operation in the
subclass that is similar to one in the parent class, but is customized
for objects of the subclass. For example, a parent class, Bird, might
have a draw method that draws a generic bird. A subclass of Bird named
Waterfowl could override the draw method inherited from Bird to draw a
generic waterfowl, perhaps a duck.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>7. What is dynamic dispatch?</b></span><br />
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.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>8. What is an abstract method? What is an abstract class?</b></span><br />
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++).</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>10. What is an inner class?</b></span><br />
Inner classes are non-static classes that are nested directly in another class.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>12. From where are Smalltalk objects allocated?</b></span><br />
Smalltalk objects are allocated from the heap and are referenced through reference variables, which are implicitly dereferenced.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>15. What kind of inheritance, single or multiple, does Smalltalk support?</b></span><br />
Smalltalk supports single inheritance; it does not allow multiple inheritance.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>19. How are C++ heap-allocated objects deallocated?</b></span><br />
C++ heap-allocated objects are deallocated using destructor.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>29. Does Objective-C support multiple inheritance?</b></span><br />
No Objective-C doesn’t support it. (It supports only single inheritance).</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>33. What is the purpose of an Objective-C category?</b></span><br />
The purpose of an Objective-C category is to add certain functionalities
to different classes and also to 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.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>38. What is boxing?</b></span><br />
Boxing is primitive values in Java 5.0+ which is implicitly coerced when
they are put in object context. This coercion converts the primitive
value to an object of the wrapper class of the primitive value’s type.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>39. How are Java objects deallocated?</b></span><br />
By implicitly calling a <i>finalize</i>method when the garbage collector is about to reclaim the storage occupied by the object.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<hr />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<br />
<span style="font-size: x-large;"><span style="color: red;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>Problem Set</b></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b><br /></b></span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b><br /></b></span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>1 . What important part of support for inheritance is missing in Java?</b></span><br />
Java does not support the private and protected derivations of C++. One
can surmise that the Java designers believed that subclasses should be
subtypes, which they are not when private and protected derivations are
supported. Thus, they did not include them.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<br />
<span style="font-size: large;"><span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>3. Compare the inheritance of C++ and Java.</b></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">In Java, all classes inherit from the Object class directly or
indirectly. Therefore, there is always a single inheritance tree of
classes in Java, and Object class is root of the tree. In Java, if we
create a class that doesn’t inherit from any class then it automatically
inherits from Object Class. In C++, there is forest of classes; when we
create a class that doesn’t inherit from anything, we create a new tree
in forest.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">In Java, members of the grandparent class are not directly accessible.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">The meaning of protected member access specifier is somewhat
different in Java. In Java, protected members of a class “A” are
accessible in other class “B” of same package, even if B doesn’t inherit
from A (they both have to be in the same package)</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Java uses <i>extends </i>keyword for inheritence. Unlike C++, Java
doesn’t provide an inheritance specifier like public, protected or
private. Therefore, we cannot change the protection level of members of
base class in Java, if some data member is public or protected in base
class then it remains public or protected in derived class. Like C++,
private members of base class are not accessible in derived class.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Unlike C++, in Java, we don’t have to remember those rules of
inheritance which are combination of base class access specifier and
inheritance specifier.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">In Java, methods are virtual by default. In C++, we explicitly use virtual keyword.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Java uses a separate keyword <i>interface </i>for interfaces, and <i>abstract </i>keyword for abstract classes and abstract functions.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Unlike C++, Java doesn’t support multiple inheritance. A class
cannot inherit from more than one class. A class can implement multiple
interfaces though.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>– </b>In C++, default constructor of parent class is
automatically called, but if we want to call parametrized constructor of
a parent class, we must use Initalizer list. Like C++, default
constructor of the parent class is automatically called in Java, but if
we want to call parametrized constructor then we must use super to call
the parent constructor</span></span></li>
</ul>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>5. Compare abstract class and interface in Java.</b></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">First and major difference between abstract class and interface is
that, abstract class is a class while interface is a interface, means by
extending abstract class you can not extend another class becauseJava
does not support multiple inheritance but you can implement multiple
inheritance in Java.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Second difference between interface and abstract class in Java is
that you can not create non abstract method in interface, every method
in interface is by default abstract, but you can create non abstract
method in abstract class. Even a class which doesn’t contain any
abstract method can be abstract by using abstract keyword.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Third difference between abstract class and interface in Java is
that abstract class are slightly faster than interface because interface
involves a search before calling any overridden method in Java. This is
not a significant difference in most of cases but if you are writing a
time critical application than you may not want to leave any stone
unturned.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Fourth difference between abstract class vs interface in Java is
that, interface are better suited for Type declaration and abstract
class is more suited for code reuse and evolution perspective.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Another notable difference between interface and abstract class is
that when you add a new method in existing interface it breaks all its
implementation and you need to provide an implementation in all clients
which is not good. By using abstract class you can provide default
implementation in super class.</span></span></li>
</ul>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>10. Explain one advantage of inheritance.</b></span><br />
Inheritance offers a solution to both the modification problem posed by
abstract data type reuse and the program organization problem. If a new
abstract data type can inherit the data and functionality of some
existing type, and is also allowed to modify some of those entities and
add new entities, reuse is greatly facilitated without requiring changes
to the reused abstract data type. Programmers can begin with an
existing abstract data type and design a modified descendant of it to
fit a new problem requirement. Furthermore, inheritance provides a
framework for the definition of hierarchies of related classes that can
reflect the descendant relationships in the problem space.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><b>12. Compare inheritance and nested classes in C++. Which of these supports an is-a relationship?</b></span><br />
Inheritance is where one class (child class) inherits the members of
another class (parent class).Nested class is a class declared entirely
within the body of another class or interface.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Inheritance does.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b><span style="color: blue;">17. </span>What are the different options for object destruction in Java?</b><br />
Finalize is related to C++ destructor. A finalize method is implicitly
called when the garbage collector is about to reclaim the storage
occupied by the object. The problem with finalize is that the time it
will run cannot be forced or even predicted. The alternative to using
finalize to reclaim resources held by an object about to be garbage
collected is to include a method that does the reclamation. The only
problem with this is that all clients of the objects must be aware of
this method and remember to call it.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>20. Compare the way Smalltalk provides dynamic binding with that of C++.</b><br />
In C++, the programmer can specify whether static binding or dynamic
binding is to be used. Because static binding is faster, this is an
advantage for those situations where dynamic binding is not necessary.
Furthermore, even the dynamic binding in C++ is fast when compared with
that of Smalltalk. Binding a virtual member function call in C++ to a
function definition has a fixed cost, regardless of how distant in the
inheritance hierarchy the definition appears. Calls to virtual functions
require only five more memory references than statically bound calls
(Stroustrup, 1988). In Smalltalk, however, messages are always
dynamically bound to methods, and the farther away in the inheritance
hierarchy the correct method is, the longer it takes. The disadvantage
of allowing the user to decide which bindings are static and which are
dynamic is that the original design must include these decisions, which
may have to be changed later.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>21. Compare the support for polymorphism in C# with that of in Objective-C.</b><br />
In Objective-C, polymorphism is implemented in a way that differs from
the way it is done in most other common programming languages. A
polymorphic variable is created by declaring it to be of type id. Such a
variable can reference any object. The run-time system keeps track of
the class of the object to which<br />
an id type variable refers. If a call to a method is made through such a
variable, the call is dynamically bound to the correct method, assuming
one exists.<br />
To allow dynamic binding of method calls to methods in C#, both the base
method and its corresponding methods in derived classes must be
specially marked. The base class method must be marked with virtual, as
in C++. To make clear the intent of a method in a subclass that has the
same name and protocol as a virtual method in an ancestor class, C#
requires that such methods be marked override if they are to override
the parent class virtual method.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>25. Study and explain private and public modifiers in C++. How do those modifiers differ in C#?</b><br />
C++ includes both classes and structs, which are nearly identical
constructs. The only difference is that the default access modifier for
class is private, whereas for structs it is public. C# also has structs,
but they are very different from those of C++. In C#, structs are, in a
sense, lightweight classes. They can have constructors, properties,
methods, and data fields and can implement interfaces but do not support
inheritance.</span></span>Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-36934192900902557802013-06-28T11:08:00.006+07:002013-06-28T11:08:46.312+07:00Chapter 11 of Concept of Programming Languages<span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong>Review Questions : </strong></span></span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;">
</span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">1. What are the two kinds of abstractions in programming languages?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>process abstraction and data abstraction</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">2. Define ADT</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>ADT is a data type that is hidden from the program units, and the
declaration of the type and the protocols, are contained in a single
syntactic unit</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">3. What are the advantages of the two parts of the definition of abstract data type?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>Information hiding, improved readability, and easier to manage</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">5. What are the language design issues for ADT?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>Form of the container for the interface to the type, whether ADT can be
parameterized, type of access controls, whether the specification of
the type is separate from its implementation</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">6. Explain how information hiding is provided in an Ada package</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>In Ada, the designer of an Ada package can choose to make the type
entirely visible to clients or provide only the interface information.</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">7. To what is the private part of an Ada package specification visible?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>The private clause is visible to the compiler but not to the client program units.</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">8. What is the difference between private and limited private types in Ada?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>Limited private type is a more restricted form of private types</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">10. What is the use of the Ada with clause?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>The with clause makes the names defined in external packages visible</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">11. What is the use of the Ada use clause?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>The use clause eliminates the need for explicit qualification of the references to the entities from the named packages.</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">12. What is the fundamental difference between a C++ Class and and Ada package?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>C++ classes are types, Ada packages are more generalized encapsulations
that can define any number of types. A c++ program unit that declares an
instance of a class can access any of the public entities in that
class, but only through an instance of the class instead of Ada package,
in which a program unit that gains visibility can access public
entities by their names</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">13. From where are C++ object allocated?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"><span style="color: black;">In the function where an object is created</span> </span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">14. In what different places can the definition of a C++ member function appear?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;">
</span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: red;"><strong> </strong></span>In the class or only in its header</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: red;"><strong>__________________________________________________________________________________________________________________________________________________________________________________ </strong></span></span></span><br />
<span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><strong>Problem Set Questions :</strong></span></span></span><br />
<span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">3. Write an analysis of the similarities of and differences between the access specifier of Java and C++</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> <span style="color: black;">Answer :</span></span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><br />C++ and Java use classes, however in Java, reliability gets prioritized
over flexibility, Java and C++ classes are very similar in the term of
using protected, public, and private. Each access specifier is the same
whether in C++ or Java, in C++ private can only be accessed inside the
class, protected is private but can be inherited to a child class, and
public is accessible from outside the class. Java however need to
specify everything in when we declare a variable, while in C+ we only
need to write protected or private only once. Method must be defined
inside of a class in Java, and all objects are allocated form the heap
and accessed through reference variables.</span></span><br />
<br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">4. What are the advantages of the nonpointer concept in Java?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>The nonpointer concept in Java basically means that pointer is no longer
included in Java. Pointer is a powerful but dangerous tool to use, A
dangling pointer can have an impact to the overall program reliability,
hence why java decided not to include pointers. The advantages is that
java program is basically more reliable, and not prone to error without
the existence of pointers.</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">9. What happens if the constructors are absent in Java and C++?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>We cannot assign values that we want on the creation time of the object,
instead we have to make a separate function to assign values, and this
can take time.</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">11. Why is the destructor of C# is rarely used?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">
</span></span></span><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"> </span>Because C# uses garbage collection for most of its heap objects.</span></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;">15. Give one capability that Java 5.0 provides which C# 2005 does not.</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"><span style="color: black;">Answer :</span></span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;"><span style="color: blue;"><span style="color: black;">One capability that Java 5.0 provides that C# 2005 does not is wildcard classes </span> </span></span></span>Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com1tag:blogger.com,1999:blog-4564297048639947475.post-39684623956233112172013-06-28T11:01:00.002+07:002013-06-28T11:01:36.026+07:00Chapter 10 of Concept of Programming Languages<span style="font-size: x-large;"><span style="color: red;"><span style="font-family: Arial,Helvetica,sans-serif;"><strong>Review Question</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>1. What is the definition used in this chapter for “simple” subprograms?</strong></span><br />
By “simple” they mean that subprograms cannot be nested and all local variables are static.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>2. Which of the caller or callee saves execution status information?</strong></span><br />
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.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><strong>4. What is the task of a linker?</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Task of a linker is to find the files that contain the translated
subprograms referenced in that program and load them into memory. Then ,
the linker must set the target addresses of all calls to those
subprograms in the main program to the entry addresses of those
subprograms.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><strong>5. What are the two reasons why implementing subprograms with
stack-dynamic local variables is more difficult than implementing
simple subprograms?</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">The compiler must generate code to cause the implicit allocation and deallocation of local variables.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Recursion adds the possibility of multiple simultaneous activations
of a subprogram, which means that there can be more than one instance
(incomplete execution) of a subprogram at a given time, with at least
one call from outside the subprogram and one or more recursive calls.
The number of activations is limited only by the memory size of the
machine. Each activation requires its activation record instance.</span></span></li>
</ul>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>11 . What is an EP, and what is it’s purpose?</strong></span><br />
EP is required to control the execution of a subprogram. Initially, the
EP points at the base, or first address of the activation record
instance of the main program. Therefore, the run-time system must<br />
ensure that it always points at the base of the activation record
instance of the currently executing program unit. When a subprogram is
called, the current EP is saved in the new activation record instance as
the dynamic link. The EP is then set to point at the base of the new
activation record instance. Upon return from the subprogram, the stack
top is set to the value of the current EP minus one and the EP is set to
the dynamic link from the activation record instance of the subprogram
that has completed its execution. Resetting the stack top effectively
removes the top activation record instance.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><strong>16 . Describe the deep-access method of implementing dynamic scoping.</strong></span><br />
If local variables are stack dynamic and are part of the activation records in a<br />
dynamic-scoped language, references to nonlocal variables can be
resolved by searching through the activation record instances of the
other subprograms that are currently active, beginning with the one most
recently activated. This concept is similar to that of accessing
nonlocal variables in a static-scoped language with nested subprograms,
except that the dynamic—rather than the static—chain is followed. The
dynamic chain links together all subprogram activation record instances
in the reverse of the order in which they were activated. Therefore, the
dynamic chain is exactly what is needed to reference nonlocal variables
in a dynamic-scoped language. This method is called deep access,
because access may require searches deep into the stack.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><hr />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"></span></span><br />
<br />
<span style="font-size: x-large;"><span style="color: red;"><span style="font-family: Arial,Helvetica,sans-serif;"><strong>Problem Set</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><strong>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.</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">One very simple alternative is to assign integer values to all
variable names used in the program. Then the integer values could be
used in the activation records, and the comparisons would be between
integer values, which are much faster than string comparisons.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><strong>8. Pascal allows gotos with nonlocal targets. How could such
statements be handled if static chains were used for nonlocal variable
access?</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Finding the correct activation record instance of a nonlocal variable
using static links is relatively straightforward. When a reference is
made to nonlocal variable, the activation record instance containing the
variable can be found by searching the static chain until a static
ancestor activation record instance is found that contains the variable.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><strong>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?</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">The nesting of scopes is known at compile time, the compiler can
determine not only that a reference is nonlocal but also the length of
the static chain that must be followed to reach the activation records
instance that contains the nonlocal object.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><br />
<br />
<span style="font-size: large;"><span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><strong>11. If a compiler uses the static chain approach to
implementing blocks, which of the entries in the activation records for
subprograms are needed in the activation records for blocks?</strong></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">A static chain is a chain of static links that connect certain
activation record instances in the stack. During the execution of a
subprogram P, the static link of its activation record instance points
to an activation record instance of P’s static parent program unit. That
instance’s static link points in turn to P’s static grandparent program
unit’s activation record instance, if there is one. So, the static
chain connects all the static ancestors of an executing subprogram, in
order of static parent first. This chain can obviously be used to
implement the accesses to nonlocal variables in static-scoped languages.</span></span>Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com2tag:blogger.com,1999:blog-4564297048639947475.post-33924686844816513052013-06-28T10:57:00.000+07:002013-06-28T11:01:53.766+07:00Chapter 9 of Concept of Programming Languanges<span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><b>Review Questions : </b></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">1. What are the three general characteristics of subprograms?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Characteristics :
</span></span><br />
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Each subprogram has a single entry point</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">The calling program unit is suspended during the execution of the
called subprgoram, which implies thtat there is only one subprogram in
execution at any given time</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Control always returns to the caller when the subprogram execution terminates</span></span></li>
</ul>
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">2. What does it mean for a subprogram to be active?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span> subprogram is said to be active, if after having been called, it has begun execution but has not yet completed that execution.</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">3. What is given in the header of a subprogram?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>The definition, a name, and a specification of parameters</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">4. What characteristic of Python subprograms sets them apart from those of other language?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>The function def statementes are executable, when def statements are executed, the functions cannot be called.</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">5. What languages allow a variable number of parameters?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>C# allows methods to accept a variable number of parameters, as long as they are the of the same type.</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">11. What are design issues for subprograms?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Design issues :
</span></span><br />
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Are the local variables statically or dynamically allocated?</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Can subprogram definitions appear in other subprogram definitions?</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">What parameter passing method are used?</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Are the type of the actual parameter checked against the type of the formal parameters?</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Can subprogram be overloaded?</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Can subprogram be generic?</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">If the language allows nested subprograms, are closure supported ?</span></span></li>
</ul>
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">12. What are the advantages and disadvantages of dynamic local variable?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>The Advantages :
</span></span><br />
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Dynamic local variable is slightly more efficient</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">They require no run time overhead for allocation or deallocation</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">They allow subprograms to be history sensitive</span></span></li>
</ul>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">The Disadvantages are :</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span>
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Their inability to support recursion</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Their storage cannot be shared with local variables</span></span></li>
</ul>
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">25. What is an ad hoc binding?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>Ad hoc binding is the environment of call statement that passed the subprogram as an actual parameter</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">34. What is a closure?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> </span>A closure is a subprogram and its referencing environment</span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">___________________________________________________ </span></span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><b>Problem Set Questions :</b></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">5.</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">void swap(int a, int b){<br />
int temp;<br />
temp = a;<br />
a = b;<br />
b = temp;<br />
}</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">int main(){</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">int value = 1, list[5] = {2,4,6,8,10};<br />
swap(value, list[0]);<br />
swap(list[0], list[1]);<br />
swap(value,list[value]);</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">}<br />
getchar();<br />
return 0;<br />
}</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">For each of the following parameter passing methods, what are all of
the values of the variables value and list after each of the three calls
to swap</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span>
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">a. Passed by value</span></span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">b. Passed by reference</span></span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">c. Passed by value-result </span></span></span></li>
</ul>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><span style="color: black;">Answer :</span></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><span style="color: black;">Passed by :
</span></span></span></span><br />
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">a. Value : 1 || List : 2,4,6,8,10</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">b. Value : 6 || List : 4,1,2,8,10</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">c. Value : 6 || List : 4,1,2,8,1</span></span></li>
</ul>
<br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">7.</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">void fun (int first, int second){<br />
first += first;<br />
second += second;<br />
}</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">void main(){<br />
int list[2] = {3,5};<br />
fun(list[0],list[1]);<br />
printf(“%d%d”,list[0],list[1]);<br />
}</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">For each of the following parameter passing methods, what are all of
the values of the variable list[0] and list[1] after each of the three
calls to swap</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span>
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">a. Passed by value</span></span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">b. Passed by reference</span></span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">c. Passed by value-result </span></span></span></li>
</ul>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"> <span style="color: black;">Answer :</span></span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><span style="color: black;">Passed by :
</span></span></span></span><br />
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">a. list[0] = 3 | list[1] = 5</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">b. list[0] = 4 | list[1] = 6</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">c. list[0] = 4 | list[1] = 6</span></span></li>
</ul>
<br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">8. Argue against Java design of not providing operator overloading.</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><span style="color: black;">Java design of not providing operator overloading means safety, however,
good programmers should be able to understand the concept of operator
overloading. Operator overloading itself while can be confusing if used
incorrectly(assigning operator + to a function that does something that
subtracts or vice versa), Operator overloading itself can be very useful
in creating a readable code. Operator overloading allow experienced
programmers to be more flexible in their work.</span> </span></span></span><br />
<br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">
</span></span></span><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;">14. Speculate on the issue of allowing function or method overloading
in some programming languages. Why are they not allowed by many
contemporary languages?</span></span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><span style="color: black;">While function/method overloading is flexible, it can also cause
confusion if the programmer were to decide to overload a lot of function
with different purposes but under the same name.</span> </span></span></span>Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-6026456467365706852013-06-28T10:47:00.003+07:002013-06-28T10:50:05.835+07:00Chapter 8 of Concept of Programming Languages<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;"><span style="color: blue;"><b><span style="color: red; font-size: x-large;">Review Question</span> </b></span></span><br />
<span style="font-size: large;"><br /></span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;"><span style="color: blue;"><b>1. What is the definition of control structure?</b></span><br />
A control structure is a control statement and the collection of statements whose execution it controls.</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;"><span style="color: blue;"><b>2. What did Bohm and Jocopini prove about flowcharts?</b></span><br />
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.</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;"><span style="color: blue;"><b>3. What is the definition of block?</b></span><br />
In Ruby, block is a sequence of code, delimited by either breves or the do and and reserved words.</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;"><span style="color: blue;"><b>4. What is/are the design issue(s) for all selection and iteration control statements?</b></span><br />
There is only one design issue that is relevant to all of the selection
and iteration control statements: Should the control structure have
multiple entries?</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;"><span style="color: blue;"><b>7. Under what circumstances must an F# selector have an else clause?</b></span><br />
An F# selector have an “else” clause if the “if” expression does return a value.</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="color: blue; font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>9. What are the design issues for multiple-selection statements?</b></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<br />
<ul>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">What is the form and type of the expression that controls the selection?</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">How are the selectable segments specified?</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">How are the case values specified?</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">How should unrepresented selector expression values be handled, if at all?</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">Is execution flow through the structure restricted to include just a single selectable segment?</span></li>
</ul>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span><span style="color: blue; font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>14. What are the design issues for all iterative control statements?</b></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<br />
<ul>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">How is the iteration controlled?</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">Where should the control mechanism appear in the loop statement?</span></li>
</ul>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span><span style="color: blue; font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>15. What are the design issues for counter-controlled loop statements?</b></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<br />
<ul>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">What are the type and scope of the loop variable?</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">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?</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">Should the loop parameters be evaluated only once, or once for every iteration?</span></li>
</ul>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span><span style="color: blue; font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>21. What are the design issues for logically controlled loop statements?</b></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<br />
<ul>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">Should the control be pretest or post-test?</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">Should the logically controlled loop be a special form of a counting loop or a separate statement?</span></li>
</ul>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span><span style="color: blue; font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>23. What are the design issues for user-located loop control mechanisms?</b></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<br />
<ul>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">Should the conditional mechanism be an integral part of the exit?</span></li>
<li><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">Should only one loop body be exited, or can enclosing loops also be exited?</span></li>
</ul>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<br />
<hr />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span><span style="color: red; font-size: x-large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>Problem Set</b></span></span><br />
<span style="font-size: large;"><br /></span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;"><span style="color: blue;"><b>1. What design issues should be considered for two-way selection statements?</b></span><br />
The design issues for two-way selectors can be summarized as follows:<br />
• What is the form and type of the expression that controls the selection?<br />
• How are the then and else clauses specified?<br />
• How should the meaning of nested selectors be specified?</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;"><span style="color: blue;"><b>4. What are the limitations of implementing a multiple selector from two-way selectors and gotos?</b></span><br />
A multiple selector can be built from two-way selectors and gotos, but
the resulting structures are cumbersome, unreliable, and difficult to
write and read.</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;"><span style="color: blue;"><b>5. What are the arguments pro and con, for Java’s approach to specify compound statements in control statements?</b></span><br />
• Compound statements are required in control statements when the body of the if or else clause requires multiple statements.<br />
• Java uses braces to form compound statements, which serve as the bodies of if and else clauses.</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="color: blue; font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b>9. Boolean expressions are necessary in the control
statements in Java, as opposed to also allowing arithmetic expressions,
as in C++. Give a conditional statement that is correct in C++ but not
in Java.</b></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<br />
<pre><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">int i=10;
if( i )
{
// block of statements
}</span></pre>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span><span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">This block of statement is valid in C++ but not in Java.</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;"><span style="color: blue;"><b>11. Explain the advantages and disadvantages of the Java switch statement, compared to C++’s switch statement.</b></span><br />
The Java variable in the argument of a switch statement can be of type
integral ( byte, short etc.), char and String( JDK 1.7 onwards), whereas
in C++ the argument can be int or char.</span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;">
</span>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: large;"><span style="color: blue;"><b>14. State one of the main legitimate needs for gotos.</b></span><br />
Premature exits from loops.</span>Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-45021503704410356562013-04-15T10:53:00.002+07:002013-04-15T10:53:52.850+07:00Chapter 7 - Concept of Programming Languages Tenth Edition - Robert Sebesta<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><b><span style="font-size: x-large;"><span style="color: red;">Review Question Chapter 7</span></span></b><br /><br /><br /><span style="color: blue;">5. What is a nonassocative operator?</span><br /><br />A nonassociative operator means that the expression is illegal.<br /><br /><br /><span style="color: blue;">6. What associativity rules are used by APL?</span><br /><br />all operators have equal precedence and all operators associate right to left.<br /><br /><br /><span style="color: blue;">8. Define functional side effect.</span><br /><br />Functional side effect occurs when the function changes either one of its parameters or a global variable.<br /><br /><br /><span style="color: blue;">9. What is coercion?</span><br /><br />A coercion is an implicit type conversion.<br /><br /><br /><span style="color: blue;">10. What is a conditional expression?</span><br /><br />a conditional expression is a statement that contains if-then-else to perform a conditional expression assignment.<br /><br /><span style="color: blue;">14. What is a mixed-mode expressions?</span><br /><br />A mixed-mode expressions is a programming language that allows an operator to have operands of different types.<br /><br /><br /><span style="color: blue;">28. What is a cast</span><br /><br />A cast in C-based languages, is an explicit type conversions.<br /><br /><br /><br /><span style="font-size: x-large;"><span style="color: red;">Problem Set Chapter 7</span></span><br /><br /><br /><span style="color: blue;">1. When might you want the compiler to ignore type differences in an expressions?</span><br /><br />When i wanted to do an operation, for example : char array with an integer (string + integer), however this is not possible and we must first convert the char array into integer(typecasting) and after that we can do the operation.<br /><br /><br /><span style="color: blue;">3. Do you think the elimination of overloaded operators in your favorite language would be beneficial? Why or why not?</span><br /><br />Yes, I do think that the elimination of overloaded operators in my favorite language would be beneficial.<br /><br />Elimination of overloaded operators would:<br /><br />- Enhance and increase readability.<br /><br />- Minimize the compiler overhead (choosing the correct operator meaning).<br /><br /><br /><span style="color: blue;">4. Would it be a good idea to eliminate all operator precedence rules and require parentheses to show the desired precedence in expressions? Why or why not?</span><br /><br />I against this idea. The amount of parentheses needed will have an impact to readability, and it will also made the programmer have more work to write the parentheses down, when you can just type it the standard way. After all that's ho<span style="font-size: large;">w the mat<span style="font-size: large;">h<span style="font-size: large;">'s work</span></span></span><br /><br /><br /><span style="color: blue;">5. Should C’s assigning operations (for example, +=) be included in other languages (that do not already have them)? Why or why not?</span><br />Personally, i myself prefer to use x = x + y due to the readability, some people uses x += y. But it still okay to implement this type of operator in other languages.<br /><br /><br /><span style="color: blue;">7. Describe a situation in which the ad operator in a programming language would not be communicative</span><br /><br />An expression such as x + fun(y).<br /><br /><br /><span style="color: blue;">21. Why does Java specify that operands in expressions are all evaluated in left-to-right order ?</span><br /><br />Java has well defined rules for specifying order in which in expression are all evaluated in left-to-right order, this is done to make Java easier to code, as left-to-right order is how most of us learned it in our early school on the mathematics subject. left-to-right order is also one of the most used guidelines in order to evaluate operands in an expression. This is also done to prevent functional side effect from happening.</span></span>Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-717052785129206312013-04-15T10:28:00.000+07:002013-04-15T10:28:13.359+07:00Chapter 6 - Concept of Programming Languages Tenth Edition - Robert Sebesta<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><b><span style="font-size: x-large;">Review Question chapter 6</span></b></span><br /><br /><span style="color: blue;">15. What is an aggregate constant?</span><br /><br />A parenthesized lists of values.</span></span><br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><br /><br /><span style="color: blue;">16. What array operations are provided specifically for single-dimensioned arrays in Ada?</span><br /><br />catenation specified by the ampersand (&).<br /><br /><br /><span style="color: blue;">17. Define row major order and column major order.</span><br /><br />Row major order (by rows) – used in most languages<br />Column major order (by columns) – used in Fortran<br /><br /><br /><span style="color: blue;">18. What is an access function for an array?</span><br />Access function maps subscript expressions to an address in the array<br /><br /><br /><span style="color: blue;">20. What is the structure of an associative array?</span><br /><br />An associative array is an unordered collection of data elements that are indexed by an equal number of values called keys. User-defined keys must be stored.<br /><br /><br /><span style="color: blue;">21. What is the purpose of level numbers in COBOL records?</span><br /><br />COBOL uses level numbers to show nested records; others use recursive definition<br /><br /><br /><span style="color: blue;">22. Define fully qualified and elliptical references to fields in records.</span><br /><br />Fully qualified references must include all record names.<br />Elliptical references allow leaving out record names as long as the reference is unambiguous.<br /><br /><br /><span style="color: blue;">23. What is the primary difference between a record and a tuple?</span><br /><br />record is an aggregate of data elements in which the individual elements are identified by names and accessed through offsets from the beginning of the structure.<br />tuple is a data type that is similar to a record, except that the elements are not named.<br /><br /><br /><span style="color: blue;">24. Are the tuples of Python mutable?</span><br /><br />Python includes an immutable tuple type<br /><br /><br /><span style="color: blue;">25. What is the purpose of an F# tuple pattern?</span><br /><br />A tuple pattern is simply a sequence of names, one for each element of the tuple , with or without the delimiting parentheses.<br /><br /><br /><span style="color: blue;">26. In what primarily imperative language do lists serve as arrays?</span><br />Python<br /><br /><br /><span style="color: blue;">27. What is the action of the Scheme function CAR?</span><br /><br />The CAR function returns the first element of its list parameter.<br /><br /><br /><span style="color: blue;">28. What is the action of the F# fuction tl?</span><br /><br />it is the methods of the List class, as in List.hd[1; 3; 5; 7], which returns 1. <br /><br /><br /><span style="color: blue;">30. On what are Python’s list comprehensions based?</span><br /><br />A list comprehension is an idea derived from set notaion.<br /><br /><br /><b><span style="font-size: x-large;"><span style="color: red;">Problem Set Chapter 6</span></span></b><br /><br /><br /><span style="color: blue;">1. What are the arguments for and against four signed integer sizes in Java?</span><br /><br />bytes (1 byte), short(2 bytes), integer (4 bytes), long (8 bytes). As a result, depending on the domain of the variable required, data types are used.<br /><br /><br /><span style="color: blue;">2. How are negative integers stored in memory?</span><br />Negative integer is stored in memory, and in most modern computer, the one on the most left (the sign bit) usually determines the sign for that integer.<br /><br /><br /><span style="color: blue;">6. Compare the use of Boolean data types in C++ and Java. Give emphasis on their use in conditional statements and conditional loops</span><br /><br />C++ and Java boleaan usage is not different excpet in C++ the type is “bool” and in java it’s “boolean”, boolean data type only contains true or false, and this is usually used in a conditional statement or loops.<br /><br /><br /><span style="color: blue;">7. Compare the pointer and reference type variable in C++</span><br /><br />The relationship to C pointers is that, Reference type is less powerful but safer than the pointer type inherited from C. C++ References are different from pointer in some ways<br /></span></span><br />
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"> It is not possible to refer directly to a reference object after it is defined</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"> Once a reference is created, it cannot be later made to reference another object, it cannot be reseated.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"> References cannot be NULL, every reference refers to some object although it may or may not valid.</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"> Reference cannot be Uninitialized</span></span></li>
</ul>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><br />However, reference can still be invalid if the previously valid reference:<br /></span></span><br />
<ul>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"> referred to an object with automatic allocation which goes out of scope</span></span></li>
<li><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"> referred to an object inside a block of dynamic memory which has been freed.</span></span></li>
</ul>
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><br /><br /><span style="color: blue;">9. C provides two derived data types both for name and structure type equivalence: struct and union. Make a study on when to use struct type variables and union type variables</span><br />Union is used to save space. When we want to use one of the members of the union, rather than waste space for a lot of them. While in a struct, each data is located separated in memory address, therefor consuming more memories.<br /><br /><br /><span style="color: blue;">21. In what way is dynamic type checking better than static type checking?</span><br /><br />In Dynamic typing, we don’t need to initialize variables, Dynamic typing in practice, saves programmer from writing a few extra lines of codes.</span></span>Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-34137230109794286852013-04-12T23:01:00.005+07:002013-04-12T23:01:54.803+07:00Chapter 5 - Programming Languages Concept - Tenth Edition - Robert Sebesta<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: red;"><span style="font-size: x-large;"><b>Review chapter 5</b></span></span><br /><br /><span style="color: blue;">1. What are the design issues for names ?</span><br />case sensitivity and special words of the language and keyboard<br /><br /><span style="color: blue;">2. What is the potential danger of case-sensitive names ?</span><br />Case sensitivity causes a serious detriment to readability, and violates the design principle that language constructs, that look similar should have similar meaning<br /><br /><span style="color: blue;">4. What is an alias ?</span><br />alias is an variable name that can be used to access same memory locations and variables<br /><br /><span style="color: blue;">7. Define binding and binding time</span><br />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<br />Binding time is time at which a binding takes place<br /><br /><span style="color: blue;">9. Define static binding and dynamic binding</span><br />Static binding is the condition if the binding occurs before the run tume begins and remains unchanged throughout program execution<br />dynamic binding is the condition if the binding first occurs during run time or can change in the course of program execution<br /><br /><span style="color: blue;">18. What is a block ?</span><br />a block are variables that typically stack dynamic, so their storage is allocated when the section is entered and deallocated when the section is exited<br /><br /><br /><span style="color: red;"><span style="font-size: x-large;"><b>Problem set</b></span></span><br /><br /><br /><span style="color: blue;">1. Decide which of the following identifier names is valid in C<span style="font-size: large;"> </span>language. Support your decision.<br />
_Student<br />
Int<br />
123Student<br />
Student123</span></span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Following Identifier<br /> a. _Student = Allowed, Rarely used, doesn’t really affect anything<br /> b. int = Not allowed, because it will be confusing to have a variable name as the type specifiers<br /> c. 123Student = Not allowed, the variable name look messy and can be confusing if used extensively.<br /> d. Student123 = Allowed, handy in case we want to separate a variable that we clearly know the purpose (For example we usually use x to measure length, we can type x1 for the first length, and x2 for the second length).<br /><br />6. </span><span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;">Consider the following JavaScript skeletal program:<br />
// The main program<br />
Var x;<br />
Function sub1() {<br />
Var x;<br />
Function sub2(){<br />
…<br />
}<br />
}
</span></span></span><br />
<span style="color: blue;"><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Function sub3(){<br />
…<br />
}<br />
Assume that the execution of this program is in the following unit order:<br />
Main calls sub1<br />
Sub1 calls sub2<br />
Sub2 calls sub3<br />
a. Assuming static coping, in the following, which declaration of x is the correct one for a reference to x?<br />
i. Sub1<br />
ii. Sub2<br />
iii. Sub3</span></span></span><br />
<span style="color: blue;"><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">
</span></span></span><span style="color: blue;"><span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">b. Repeat part , but assume dynamic scoping.</span></span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Scope<br /><br />a. Static :<br /><br /> 1. Sub1 : sub1<br /> 2. Sub2 : sub1<br /> 3. Sub3: main<br /><br />b. Dynamic :<br /><br /> 1. Sub1 : sub1<br /> 2. Sub2 : sub1<br /> 3. Sub3: sub1<br /><br /><span style="color: blue;">7. Assume the following JavaScript program was interpreted using
static-scoping rules. What value of x is displayed in function sub1?
Under dynamic-scoping rules, what value of x is displayed in sub1?
</span></span></span><br />
<span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;">var x;<br />
function sub1() {<br />
document.write(“X=”+x+”<br />”);<br />
}<br />
function sub2() {<br />
var x;<br />
x=10<br />
sub1();<br />
}<br />
x=5;<br />
sub2();</span></span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Static Scope then x = 5, if Dynamic Scope then x = 10<br /><br /><span style="color: blue;"><span style="font-size: large;">10. </span>Consider the following C program
</span></span></span><br />
<span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;">void fun(void) {<br />
int a, b, c; // definition 1<br />
…<br />
while ( …) {<br />
int b, c, d; // definition 2<br />
… <-1<br />
while (…) {<br />
int c, d, e; // definition 3<br />
… <- 2<br />
}<br />
… <- 3<br />
}<br />
… <- 4<br />
}</span></span></span><br />
<span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;">
</span></span></span><span style="color: blue;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: large;">For each of the four marked points in this function, list each
visible variable, along with the number of the definition statement that
defines it.</span></span></span><br />
<br />
<span style="font-size: large;"><span style="font-family: Arial,Helvetica,sans-serif;">Points:<br /><br />1) Variables :<br /> a = 1 b = 2<br /> c = 2 d = 2<br />2) Variables :<br /> a = 1 b = 2<br /> c = 3 d = 3<br /> e = 3<br />3) Variables :<br /> a = 1 b = 2 <br /> c = 2 d = 2<br />4) Variables :<br /> a = 1<br /> b = 1<br /> c = 1</span></span>Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-86728643883988422062013-03-26T15:45:00.000+07:002013-03-26T15:45:03.008+07:00Review & Problem Set for Chapter 3 from Concepts of Programming Languages Tenth Edition by Robert Sebesta<span style="font-size: large;"><b><span style="color: red;"><span style="font-size: x-large;">REVIEW Chapter 3</span></span><br /><br /><span style="color: blue;">1. Define syntax and semantics.</span><br />the syntax of a programming language is the form of its expressions, statements, and program units. Its semantics is the meaning of those expressions, statements, and program units.<br /><br /><span style="color: blue;">3. Describe the operation of a general language generator.</span><br />Language generator is a device that can be used to generate the sentences of languages. Language generator operates by generating a sentence of language, however language generators is unpredictable.<br /><br /><span style="color: blue;">5. What is the difference between a sentence and a sentential form?</span><br />The difference is that a sentential form is any string derivable from the start symbol while sentence is a sentential form which contains only terminal symbols.<br /><br /><span style="color: blue;">6. Define a left-recursive grammar rule.</span><br />A left recursive grammar rule is a grammar rule that has its left hand side also appearing at the beginning of its RHS, this left recursion specifies left associatively.<br /><br /><span style="color: blue;">8. Distinguish between static and dynamic semantics.</span><br />The static semantic define restriction on the structure of valid texts that are hard or impossible to express ins standard syntactic formalisms while dynamic semantic defines how and when the various constructs of a language should produce a program behavior.<br /><br /><span style="color: blue;">10. What is the difference between a synthesized and an inherited attribute?</span><br />The synthesized attributes are the result of the attribute evaluation rules, and may also use the values of the inherited attributes. The inherited attributes are passed down from parent nodes. In some approaches, synthesized attributes are used to pass semantic information up the parse tree, while inherited attributes help pass semantic information down it.<br /><br /><span style="color: blue;">12. What is the primary use of attribute grammars?</span><br />An attribute grammar is a device used to describe more of the structure of a programming language than is possible with a context-free grammar. An attribute grammar is an extension to a context-free grammar. The primary purpose of an attribute grammar is it allows certain language rules to be described, such as type of compatibility. An attribute grammar is a formal way to define attributes for the productions of a formal grammar, associating these attributes to values.<br /><br /><span style="color: blue;">19. What two things must be defined for each language entity in order to construct a denotational description of the language?</span><br />objects and functions<br /><br /><span style="color: blue;">20. Which part of an inference rule is the antecedent?</span> </b></span><br />
<span style="font-size: large;"><b><span style="font-size: large;">T</span>he antecedent<span style="font-size: large;"> is the top part of an inference rule.</span><br /><br /><span style="color: blue;">21. When a grammar rule said to be left recursive?</span><br />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.<br /><br /><br /><span style="color: red;"><span style="font-size: x-large;">PROBLEM SET Chapter 3</span></span><br /><br /><span style="color: blue;">1.<span style="color: black;"><span style="font-size: large;"> </span></span>Syntax Error and semantic error are two types of compilation error. Explain the difference between the two in a program with examples</span><br />Syntax error is due to we doesn't follow the rule of a language and the compiler/interpreter unable to recognize, for example in C, missing a semicolon, will result in a syntax error. While semantic error is a logical error, for example 5 + 5 = <span style="font-size: large;">7</span>.<br /><br /><span style="color: blue;">3. Rewrite the BNF of example 3.4 to represent operator – and operator / instead of operator + and operator *.</span><br />. <assign> => <id> = <expr><br /><br />. <id> => A|B|C<br /><br />. <expr>=> <expr> – <term> | <term><br /><br />. <term> => <term> / <factor> | <factor><br /><br />. <factor>=> (<expr>) | <id><br /><br /><br /><span style="color: blue;">10.<span style="font-size: large;"> </span>Describe, in English, the language defined by the following grammar:<br /><br /><S> -> <X> <Y><br /><br /><X> -> x<X> | x<br /><br /><Y> -> y<Y> | y</span><br /><br />Answer :<br /><S> -> <X> <Y><br /><br />S is defined as the statement <X> <Y><br /><br />. <X> -> x<X> | x<br /><br />while <X> itself is defined as x<X> or just x(this statement is able to loop back to X so that X can contain x inside the function. This will result in an k number of x<br /><br />. <Y> -> y<Y> | y<br /><br />while <Y> is defined as y<Y> or just y(this statement is able to loop back to y so that Y can contain a inside the function. This will result in an j number of y (same case as X)<br /><br />because X can contain k number of x and Y can contain j number of y, this will result in <S> -> k*<x >j*<y> whereas k is >= 1 and j is >= 1 therefore allowing unlimited amount of x and y.<br /><span style="color: blue;"> </span></b></span><br />
<span style="font-size: large;"><b><span style="color: blue;">11.<span style="font-size: large;"> </span>Consider the following grammar:<br /><br /><S> -> <A>a <B> b<br /><br /><A> -> <A>b | b<br /><br /><B> -> a<B> | a</span><br /><br />Answer :<br />in my opinion, none of those are the language generated by the grammar, it should be k<A>aj<B>b,(A contains b and B contains a) in which the end will be a single b, the list of answer does not include an answer that ends with a single b<br /><br /><span style="color: blue;">13.<span style="color: black;"><span style="font-size: large;"> </span></span>Write a grammar for the language consisting of strings that have n copies of the letter a followed by double the number of copies of the letter b where n > 0. For example, the string abb, aabbbb, and aaaabbbbbbbb are in the language byt a, aabb, ba, and aaabb are not.</span><br /><S> => a<S>bb<S> | abb<br /><br /><br /><span style="color: blue;">15. Convert the BNF of example 3.1 to EBNF.</span><br />. <program> -> begin <stmt_list> end<br /><br />. <stmt_list> -> stmt[stmt_list]<br /><br />. <stmt> -> <var> = <expressions><br /><br />. <var> -> A| B | C<br /><br />. <expressions> -> <var> {(+|-)< var> }<br /><br /><br /><span style="color: blue;">16. Convert the BNF of example 3.3 to EBNF.</span><br />. <assign> -> id = <expr><br /><br />. <id> -> A|B|C<br /><br />. <expr> -> <expr> {(+ | *) <expr>) | <id><br /><br /><br /><span style="color: blue;">17. Convert the following EBNF to BNF:<br /><br />S -> a{bA}<br /><br />A ->a[b]A</span><br /><br />Answer :<br /><br />. S -> A | AX<br /><br />. X -> bA | bAX<br /><br />. A -> aA | abA<br /><br /><br /><span style="color: blue;">18. What is a fully attributed parse tree?</span><br />A fully attributed parse tree is a parse tree which are the attributes in all its nodes are computed.</b></span>Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com2tag:blogger.com,1999:blog-4564297048639947475.post-51971156310256201212013-03-12T21:01:00.001+07:002013-03-26T15:02:46.284+07:00Assignment for Programming Language Concept<span style="font-size: large;"><u><b>Review Chapter 2</b></u></span><br />
<br />
<b><span style="font-size: large;">from Concept of Programming Languages (Tenth Edition) by Robert Sebesta</span></b><br />
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;">1. Plankaltul designed between 1936 and 1945, while published in 1972</span></b><br />
<br />
<b><span style="font-size: large;">2. Plankaltul has some advanced features in data structure area and what most interesting was the inclusion of mathematical expressions showing relations between the variables</span></b><br />
<br />
<b><span style="font-size: large;">3. Plankaltul mean program calculus</span></b><br />
<br />
<b><span style="font-size: large;">4. Speedcoding include the operations of floating-point operators and include the novel facility of automatically incrementing address register</span></b><br />
<br />
<b><span style="font-size: large;">5. the words of UNIVAC 1's memory had 72 bits, grouped as 12 six-bit bytes'</span></b><br />
<br />
<b><span style="font-size: large;">6. IBM 704 has indexing and floating-point instructions in hardware, heralded the end of the interperative era</span></b><br />
<b><span style="font-size: large;">7. John Backus is the one who developed the speed coding for IBM 701</span></b><br />
<br />
<b><span style="font-size: large;">8. Short Code was developed by John Mauchly, short code wasn't translated to the machine code, rather it was implemented with a pure interpreter, therefore it was the cause this programming called automatic programming</span></b><br />
<br />
<b><span style="font-size: large;">10. One of the significant features of Fortran 2 that Fortran 1 don't have is the independent compilation of sub-routines</span></b><br />
<br />
<b><span style="font-size: large;">11. Fortran 77 retained most of the features of Fortran IV, and added with character string handling, logical loop control statement, and modules</span></b><br />
<br />
<b><span style="font-size: large;">12. Fortran 90 is the first one who has the dynamic variables</span></b><br />
<br />
<b><span style="font-size: large;">13. Fortran 77 is the first one who implemented character string handling</span></b><br />
<br />
<b><span style="font-size: large;">14. The linguist is concerned with the natural language processing, one of the beginning reasoning to AI development</span></b><br />
<br />
<b><span style="font-size: large;">15. Pure LISP has only two kinds of data structures : atom and lists.</span></b><br />
<br />
<b><span style="font-size: large;">16. Scheme is a small language with simple semantics and syntax, because of this, Scheme is well suited for education purpose, while common LISP is a large and complex language with a primitive functions</span></b><br />
<br />
<b><span style="font-size: large;">18. Algol 60 is a joint language project by GAMM ( german acronym for Society for applied Mathematics and Mechanics) and ACM (Association for Computer Machinery)</span></b><br />
<br />
<b><span style="font-size: large;">22. COBOL was based on FLOW-MATIC language, that was implemented in 1957</span></b><br />
<br />
<b><span style="font-size: large;">23. COBOL design project begin on May 28,29, 1959 at the Pentagon</span></b><br />
<br />
<b><span style="font-size: large;">24. The hierarchical data structures which is first appeared in </span></b><br />
<b><span style="font-size: large;">the Plankatul were first implemented in COBOL</span></b><br />
<br />
<b><span style="font-size: large;">26. The original BASIC only have floating point data type</span></b><br />
<b><span style="font-size: large;"><br /></span></b>
<span style="font-size: x-large;"><b><u>Problem set</u></b></span><br />
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;">5. i think one of the most hard to achieve is to speed for compiling process for a variety of programs, because computers at that time was expensive and have small memory and relatively unreliable</span></b><br />
<br />
<b><span style="font-size: large;">11. i personally think IBM is correct because trying to create an universal language that can be used in every aspect is good, but it would cause the language itself becoming a complex and large memory consumption, the downside is that</span></b><br />
<br />
<b><span style="font-size: large;">12. Procedural language determines WHAT & HOW a process should be done, Non-procedural language is concerned with the WHAT not the HOW. Non-procedural languages are those languages where you specify what conditions the answer should satisfy, but not how to obtain it.</span></b><br />
<br />
<b><span style="font-size: large;">13. In my opinion, C was a multipurpose language with wide variety and easy to understand, while Fortran is a scientific language, so people would prefer C than Fortran</span></b><br />
<br />
<b><span style="font-size: large;">14. i think the plus of type less language is made the programmer to be creative and, there are no restriction to the use of types, but the minus is the program would be hard to recognize and could become confusing, because there are no boundary between types</span></b><br />
<br />
<b><span style="font-size: large;">15. yes, SQL and Visual Basic</span></b><br />
<br />
<b><span style="font-size: large;">16. because the more simpler the language made it easier to modify and improves it readability to another programmer</span></b><br />
<br />
<b><span style="font-size: large;">17. Usually language design by committe are limited with the "goals" they made, and they need to calculate the cost of creating process, moreover if the one creating is a business based committe, they would make it cost-effective as possible so when goes to the market, the language can be sold at a fair price</span></b><br />
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;"><br /></span></b>
<b><span style="font-size: large;"><br /></span></b>
<br />Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-44859602165612984442013-03-02T11:19:00.005+07:002013-03-26T15:01:17.345+07:00Answer for Exercise Chapter 1 - Programming Language Concept Program<span style="font-size: large;"><b>Review chapter 1</b></span><br />
<span style="font-size: large;"><b><br /></b></span>
<span style="font-size: large;"><b>1. because we need to understand the basic concept and sometimes, we can apply other languange trict to solve a problem in a higher level language</b></span><br />
<br />
<span style="font-size: large;"><b>2. because the knowledge of programming languange can made us to express new ideas and also made learning other language easier</b></span><br />
<br />
<span style="font-size: large;"><b>3. Fortran the name is a blend derived from The IBM Mathematical Formula Translating System</b></span><br />
<br />
<span style="font-size: large;"><b>4. COBOL (COmmon Business-Oriented Language)</b></span><br />
<br />
<span style="font-size: large;"><b>5. LISP ( "LISt Processing") and Prolog (a general purpose logic programming language associated with artificial intelligence and computational linguistics )</b></span><br />
<br />
<span style="font-size: large;"><b>6. UNIX, right now mostly written by C</b></span><br />
<br />
<span style="font-size: large;"><b>7. because they causing something that can be solved simple, become complex because too many combinations dan variations can be used</b></span><br />
<br />
<span style="font-size: large;"><b>8. because, if the user allowed to create a overloading operator and do not do it sensibly, it may cause reduced readability</b></span><br />
<br />
<span style="font-size: large;"><b>Case study chapter 1</b></span><br />
<span style="font-size: large;"><b><br /></b></span>
<span style="font-size: large;"><b>1. yes, because we need to understand first the command we use, instead using unknown words, it would made the problem much simpler</b></span><br />
<br />
<span style="font-size: large;"><b>2. from wikipedia, Ada Lovelace, was an English mathematician and writer chiefly known for her work on Charles Babbage's early mechanical general-purpose computer, the Analytical Engine. Her notes on the engine include what is recognized as the first algorithm intended to be processed by a machine. Because of this, she is often considered the world's first computer programmer. </b></span><br />
<br />
<span style="font-size: large;"><b>6. i believe the readability of a program is very important because it made someone else could understand what i made</b></span><br />
<br />
<span style="font-size: large;"><b>7. semi colons made the program readability increased i think because it was clear where the statement would end, but those without i believe would increase the coding time</b></span><br />
<br />
<span style="font-size: large;"><b>8. pros : this design made us easier to tell where is the error and simplicify the main program. cons : if we doesn't place the function in the right place or made too many, it would become confusing</b></span><br />
<br />
<span style="font-size: large;"><b>9. orthogonality made the data type can be used many ways and because of this the powerful structure of data structures can be made, therefore without this, the program would become very long and confusing</b></span><br />
<br />
<span style="font-size: large;"><b>12. not, because, as i know, we need to combine every aspect of a programming language, even made the function by ourself, furthermore, we would complement what missing with the other languanges trick, i would not say some is complete because can be used for many usage but because the language itself was made to be flexible</b></span><br />
<br />
<span style="font-size: large;"><b>13. the first high level language i learn is C i believe that is working with a compiler, using microsoft visual studio</b></span><br />
<br />Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-34573573300846145982012-10-12T14:12:00.002+07:002013-02-28T15:20:19.249+07:00Devil's Footprint<h1 class="with-tabs">
The Devil's Footprints</h1>
The mysterious
footprints, which appeared overnight in heavy snowfall in Southern Devon
in 1855, have never been adequately explained. According to
contemporary reports, they stretched for over a hundred miles, and went
through solid walls and haystacks, appearing on the other side as though
there was no barrier. The extent of the footprints may have been
exaggerated at the time, and they may have been the result of freak
atmospheric conditions. But in truth the 'footprints', if that is what
they were, still remain a complete mystery.<br />
On the night of the 8th of February 1855, heavy snowfall blanketed
the countryside and small villages of Southern Devon. The last snow is
thought to have fallen around midnight, and between this time and around
6.00am the following morning, something (or some things) left a myriad
of tracks in the snow, stretching for a hundred miles or more, from the
River Exe, to Totnes on the River Dart.<br />
<span class="inline inline-right" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img alt="" class="image image-_original" src="http://www.mysteriousbritain.co.uk/sites/default/files/images/devils-footprints.gif" height="289" title="" width="129" /></span>The
early risers were the first to find them, strange hoof-shaped prints in
straight lines, passing over rooftops, through walls and covering huge
areas of land. A set of the prints were even supposed to have bridged a
two mile span of the river Exe, continuing on the other side as if the
creature had walked over the water.<br />
It soon became clear that the phenomenon was widespread, and some of
the more scientifically minded examined the prints in detail. One
naturalist sketched some of the marks, and measured the distance between
them, it was found to be eight and a half inches. This spacing seemed
to be consistant wherever the tracks were measured. It was also noted
that the way in which they were set out, one in front of the other,
suggested a biped rather than a creature walking on four legs.<br />
Some clergymen suggested that the prints belonged to the Devil, who
was roaming the countryside in search of sinners (a great ploy to fill
the churches), while others rejected the idea as superstition. It is
true that a feeling of unease had spread through some of the population,
who watched carefully to see if the strange footprints would return.
They did not and after a couple of days the news spread out of Devon and
made the national press. The phenomena sparked correspondence in some
of the leading papers including the Times and the Illustrated news. This
brought more accounts to light, and led to a plethora of speculation by
eminent scientists and lay men alike.<br />
It seems that most of the Southern villages of Devon, from Totnes to
Topsham, had been inundated with the prints in all manner of
absurdities. Some stopped abruptly and continued after a large break,
others stopped at walls as high as 14 feet, only to continue on the
other side, leaving untouched snow on the top of the wall. Some were
even said to have travelled through narrow apertures such as drainpipes.<br />
The papers picked up that some kangaroos had escaped from a private
Zoo belonging to a Mr Fische at Sidmouth, but the tracks description
bears no resemblance to the tracks a kangaroo would leave. Sir Richard
Owen, the eminent Biologist, suggested that the tracks were made by
badgers, roaming the countryside in search of food. He explained the
strange shape of the prints as the result of freeze-thaw action. This
explanation only holds as much ground as the other theories given at the
time, these included roaming racoons, rats, swans, otters and the
theory that a hot air balloon passed over head trailing a rope. These
could explain some of the tracks made that night, but certainly not all
of them, unless all of the above were to blame in separate occurrences.<br />
There are similar scattered cases from other parts of the world and
also one written account in Britain. According to Ralph of Coggeshall,
(who also recorded strange arial phenomena during his era) a writer from
the 13th Century, on the 19th of July 1205 strange hoof print appeared
after a violent electrical storm. In mid July these tracks would only be
visible in the soft earth, and the electrical storm suggests some kind
of natural phenomenon as yet unknown.<br />
The Devil's Footprints remain an intriguing mystery that will only
truly be solved if the phenomenon happens again and can be examined more
closely.<br />
<br />
Source : http://www.mysteriousbritain.co.uk/england/devon/other-mysteries/the-devils-footprints.html <br />
<fieldset class="fieldgroup group-authorship">
<legend>Authorship</legend><br />
<div class="field field-type-userreference field-field-image-author-registered">
<div class="field-items">
<div class="field-item odd">
<div class="field-label-inline-first">
Image Copyright: </div>
Daniel Parkinson</div>
</div>
</div>
<div class="field field-type-userreference field-field-author-registered">
<div class="field-items">
<div class="field-item odd">
Daniel Parkinson </div>
</div>
</div>
</fieldset>
Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-41550607523663872702012-10-12T14:06:00.003+07:002013-02-28T15:20:54.927+07:00The Nameless Thing of Berkeley SquareThis unidentifiable monstrosity is said, by some, to be a vile,
phantasmagorical killer from beyond the grave… though there is some
evidence to suggest that it may be a bizarre, mutant cephalopod, which
lurks in the filthy labyrinth of the London sewer system waiting to rise
up and kill again.<span id="more-1690"></span>
<br />
Considered by most paranormal experts to fit more accurately into the
realm of haunting, the Nameless Thing of Berkeley Square has left
behind tantalizing shreds of evidence – and, unfortunately, more than
one corpse – which suggests that the “ghost,” which inhabits the 4<sup>th</sup> floor (although some claim it’s the 2<sup>nd</sup>)
of number 50 Berkeley Square, in what has been referred to as “the most
haunted house in London,” may not really be a case of spiritual
infestation at all, but rather a semi-aquatic, predatory, cryptid
phenomenon.<br />
<a href="http://americanmonsters.com/site/wp-content/uploads/2010/01/namelesshouse2.jpg" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img alt="" class="alignleft size-medium wp-image-1698" src="http://americanmonsters.com/site/wp-content/uploads/2010/01/namelesshouse2-225x300.jpg" height="300" title="namelesshouse2" width="225" /></a>Although
no one is exactly sure when the first encounter with this beast
occurred, the first known account of the “Thing” date as far back as the
early 1840′s, when 20-year-old, Sir Robert Warboys, came across strange
rumors surrounding the notorious Berkeley Square address while
imbibing at a tavern in London’s Holborn district one evening. Evidently
Warboys was a man not prone to superstitious claptrap as he derisively
dismissed the legend as “unadulterated poppycock.”<br />
Warboys’ barroom compatriots wholeheartedly disagreed with his
assessment and, in what one can only assume was an effort to knock him
down a peg or two, challenged the young noble to spend the night in the
haunted 2<sup>nd</sup> floor room. Warboys, with what was no doubt the
heady rush of alcohol fueled confidence, raised his pitcher of ale
skyward and announced to his cohorts: “I wholeheartedly accept your
preposterous harebrained challenge!”<br />
Sir Robert then proceeded to the allegedly haunted dwelling, where he
insisted the landlord allow him to spend the night in the
“ghost-filled” quarters. After some debate, the landlord reluctantly
agreed to Warboys request, but only with the caveat that the young man
be armed with a pistol and that at the first sign of anything even
remotely “out of the ordinary,” he would yank the cord that was attached
to a bell in the landlord’s room below. Warboys apparently scoffed at
the notion, but agreed to the terms.<br />
As the clock chimed midnight, Warboys settled down at a table to
await the “Thing’s” arrival. The landlord, with, what one must assume
was a great lack of enthusiasm, left his temporary tenant alone in the
dreaded room, save for his pistol and a single candle, but it wouldn’t
be long before the two would meet again.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://americanmonsters.com/site/wp-content/uploads/2010/01/nameless_corpse.jpg" style="margin-left: 1em; margin-right: 1em;"><img alt="" class="alignright size-medium wp-image-1714" src="http://americanmonsters.com/site/wp-content/uploads/2010/01/nameless_corpse-300x222.jpg" height="222" title="nameless_corpse" width="300" /></a></div>
Less than an hour following the landlord’s departure, at precisely
Forty-five minutes past the hour, the proprietor was startled from an
unfit slumber by the violent clanging of the bell adjacent to his bed.
Before he even had time to clear his thoughts and react, a gunshot
echoed from above his room. With a burst of adrenaline, the landlord
leapt from his bed, and climbed the stairs at a rapid pace. When he
arrived at the door to the notorious room, he pushed it open to reveal a
sight which he would never forget…<br />
The
room was apparently unchanged except for the notable fact that Sir
Robert had left his perch at the table and was now wedged in the corner
of the room, the still smoking pistol caught in his white-knuckled grip
of his fear contorted corpse.<br />
In the very short time the landlord spent in the room he noted that
Warboys’ his lips were peeled back from his clenched teeth in a grimace
of horror and eyes seemed to be literally bulging from his skull. The
landlord followed Sir Robert’s gaze to a lone bullet hole in the
opposite wall and speculated that Warboys had fired at the infamous
“Thing,” but, for reasons he could not surmise, the bullet had had no
effect on the beast.<br />
There can be no doubt that 50 Berkeley Square can boast a horrific
array of ostensibly paranormal encounters (ranging from strange sounds
reported by neighbors to the confirmed deaths of guests and domestic
servants,) but there is one confrontation which has become the benchmark
of this legend.<br />
Just three years following the horrific death of Sir Robert Warboys,
50 Berkeley Square became the sight of yet another gruesome demise.
Although the details of this narrative have varied in minor degrees from
one retelling to another, the core of the account has always remained
the same:<br />
<a href="http://americanmonsters.com/site/wp-content/uploads/2010/01/nameless_sailors.jpg" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="" class="alignleft size-medium wp-image-1718" src="http://americanmonsters.com/site/wp-content/uploads/2010/01/nameless_sailors-261x300.jpg" height="300" title="nameless_sailors" width="261" /></a>In
1943, two sailors from Portsmouth, Robert Martin and Edward Blunden,
after having squandered their lodging funds on an evening of drunken
ribaldry, noticed a “To Let” on the then abandoned Berkeley Square abode
and managed to break into a basement window of the dwelling in search
of a night’s rest. Discovering that the lower level of the house was
uncomfortably damp (not to mention rat infested,) the sailors migrated
upwards, finally settling down in the now notorious room.<br />
Blunden, presumably the more sober of the two, expressed the anxiety
he felt upon entering the room. He claimed that he felt a “presence,”
but these fears were promptly dismissed by his shipmate, who used his
rifle to prop open a window to allow for a breeze and built a fire in
the long unused hearth with bits of broken furniture and rotting
floorboards. It wasn’t long before the two men were huddled on the
relative warmth of floor, fast asleep.<br />
Sometime after midnight Blunden awoke to see the door to the room
creaking open. Little by little a sliver of dim, grayish light crept
across the wooden floor. Too terrified to move, Blunden managed to wake
his accomplice. The two men sat up as they heard a strange, moist,
scraping sound slowly approach them. Later, Martin claimed that it
sounded as if something were dragging itself across the floor.<br />
<a href="http://www.robotoperatormanuals.com/film/monsterhouse/MHencyclopedia.html" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img alt="" class="alignright size-medium wp-image-1720" src="http://americanmonsters.com/site/wp-content/uploads/2010/01/nameless2-256x300.jpg" height="300" title="nameless2" width="256" /></a>Suddenly,
the terrified men leapt to their feet and came face to face with the
abhorrent visage of what could only describe as a hideous monstrosity.
The creature undulated between the sailors and what was their only hope
for escape; the open door. Then, just as the trembling Blunden began to
reach toward the rifle, which was still wedged in the window frame, the
creature suddenly lunged forward, wrapping itself around the young
sailor’s throat.<br />
Seizing the opportunity, the panic stricken Martin ran from the
house, screaming for help. Soon enough he stumbled upon a patrolling
police officer. Although skeptical of the young sailor’s frenzied tale
(and no doubt attributing it to the almost overwhelming stench of
alcohol which permeated his uniform) the officer dutifully followed
Martin back to Berkeley Square.<br />
<a href="http://americanmonsters.com/site/wp-content/uploads/2010/01/namelessnewspaper.jpg" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="" class="alignleft size-medium wp-image-1733" src="http://americanmonsters.com/site/wp-content/uploads/2010/01/namelessnewspaper-181x300.jpg" height="300" title="namelessnewspaper" width="181" /></a>According
to the account, Martin and the officer ran up the stairs, but found no
sign of Blunden in the room. Martin reclaimed his rifle as the two men
continued to search the house. Their efforts seemed to prove fruitless
however, until the men entered the basement and were greeted to a
ghastly image that would haunt them for the remainder of their lives…<br />
Lying at the base of the stairs in Berkeley Square’s moist, rock
walled cellar was Blunden’s dismembered corpse. His body lay in a
mangled heap, with his head wrenched viciously to the side. The officer
reported that the young man’s eyes (much like those of Sir Robert
Warboys) were wide with unimaginable horror.<br />
This appalling tale, like so many legends of this ilk, has also been
recounted with a decidedly more phantasmal twist. The most notable
variation in this retelling is the description of the “Thing” as a
shadowy man-like figure with a deformed face and body that burst in on
the sailors and proceeded to strangle Blunden with “cold, misty looking
hands.”<br />
Yet another discrepancy has Blunden perishing not in the basement,
but being hurled from the window and impaled on a spike on the wrought
iron fence that surrounded Berkeley Square. It’s these incongruities
that have led many investigators to file this case under the
“paranormal” banner, assuming that it is just another ghost story, but
there is intriguing (though admittedly scant) evidence to suggested that
this may be a genuine, albeit exceedingly bizarre, corporeal entity.<br />
<a href="http://artoferichu.com/blog/octopus-monster/" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img alt="" class="size-medium wp-image-1730 alignright" src="http://americanmonsters.com/site/wp-content/uploads/2010/01/nameless4-300x214.jpg" height="214" title="nameless4" width="300" /></a>While
these shocking encounters leave more questions as to the “Thing’s”
identity than answers, there are other alleged eyewitness accounts,
which can help us to paint a more complete picture of this creature.<br />
Some have described as an amorphous being, formless and slimy, which
emits a “gruesome sloppy noise” when it moves; while others insist it is
a dark, shapeless, spectral form, which was described as a “collection
of shadows,” that attacks its victims with clawed feet and razor sharp,
bird-like talons. Though accounts conflict regarding the actual shape
and size of the beast, at least one eyewitness has included tentacles in
his description of the creature, likening the fiend to a small,
viciously deformed octopus, which pulls itself across the floor, leaving
a viscous trail in its wake.<br />
<a href="http://americanmonsters.com/site/wp-content/uploads/2010/01/nameless_london_sewer6.jpg" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img alt="" class="alignleft size-medium wp-image-1744" src="http://americanmonsters.com/site/wp-content/uploads/2010/01/nameless_london_sewer6-300x224.jpg" height="224" title="nameless_london_sewer6" width="300" /></a>This description has led some researchers to speculate that the Thing may actually be some kind of mutated <a href="http://americanmonsters.com/site/2009/12/freshwater-octopi-eastern-usa/" target="_">FRESHWATER OCTOPI</a>
or an unknown, amphibious, marine animal that managed to migrate from
the Thames into London’s vast subterranean sewer system, where it was
able to infiltrate the Berkeley Square home via the plumbing. It can
also be speculated that this beast was looking to feed on the ample rat
population that dwelt in the house, when it accidentally stumbled across
the more “substantial” prey of the drunken sailors.<br />
In the 1920s, eminent psychic investigator Harry Price revealed a
plethora of data regarding earlier encounters with the “Thing.” While
pouring over scads of newspaper articles, he came across a story from
1790 that claimed 50 Berkeley Square once housed the headquarters for a
crew of counterfeiters. Price speculated (rather dubiously) that the
counterfeiters — in a plot lifted right from Scooby-Doo — had concocted
the spooky tale to frighten off curious onlookers and provide a
“spectral” cover for the noisy processes that accompanied their illicit
nocturnal activities.<br />
Price also managed to turn up another 1840 account of bizarre noises
(including bells, loud footsteps and heavy dragging sounds) emanating
from the house that were so rambunctious a cadre of courageous neighbors
felt obliged to search the abode, to no avail. He also came across an
1870 article published in the magazine “Notes and Queries,” by W. E.
Howlett, which stated:<br />
“The mystery of Berkeley Square still remains a mystery. The story
of the haunted house in Mayfair can be recapitulated in a few words; the
house contains at least one room of which the atmosphere is
supernaturally fatal to body and mind. A girl saw, heard and felt such
horror in it that she went mad, and never recovered sanity enough to
tell how or why.”<br />
“A gentleman, a disbeliever in ghosts, dared to sleep in number 50
and was found a corpse in the middle of the floor after frantically
ringing for help in vain. Rumour suggests other cases of the same kind,
all ending in death, madness, or both as a result of sleeping, or trying
to sleep in that room. The very party walls of the house, when touched,
are found saturated with electric horror. It is uninhabited save by an
elderly man and his wife who act as caretakers; but even these have no
access to the room. This is kept locked, the key being in the hands of a
mysterious and seemingly nameless person who comes to the house once
every six months, locks up the elderly couple in the basement, and then
unlocks the room and occupies himself in it for hours.”<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://americanmonsters.com/site/wp-content/uploads/2010/01/nameless_maggs.jpg" style="margin-left: 1em; margin-right: 1em;"><img alt="" class="alignright size-medium wp-image-1747" src="http://americanmonsters.com/site/wp-content/uploads/2010/01/nameless_maggs-300x239.jpg" height="239" title="nameless_maggs" width="300" /></a></div>
Price also noted that while 50 Berkeley Square was located on a piece
real-estate wedged in one of London’s most enviable districts, it had
remained vacant for inexplicably long stretches of time. His personal
conclusion of the whole affair was that “a particularly nasty
poltergeist had been active at number 50 in the 1840s, but doubted that
the ‘thing’ was still at large”.<br />
Since 1853, the ground floor of the house on Berkeley Square has played host to an antique bookshop known as <a href="http://www.maggs.com/" target="_">Maggs Brothers</a>.
Although there have been no reported sightings of the creature in the
20th century, it has been noted that employees of the bookshop are not
allowed to go up to the top floor. They say a police notice hangs on the
wall inside the house that was put up in the 1950s. It states that the
top floor of the house is not to be used, even for storage… No one is
exactly sure why.<br />
Although in a case like this it is difficult to separate truth from
legend, one likely reason that there have been no recent encounters with
this beast is the fact that (if this creature indeed has oceanic roots)
it has, in all likelihood, returned to the fathomless depths of the
sea, or — more chillingly — it and its offspring may still be lurking in
the labyrinth of centuries old tunnels, which weave their way beneath
Great Briton’s capitol city, feeding on rats, waiting to crawl back up
from the sewer to claim more human victims.<br />
<br />
source : http://www.americanmonsters.com/site/2010/01/nameless-thing-of-berkeley-square-england/ Anonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0tag:blogger.com,1999:blog-4564297048639947475.post-29257193217518560182012-10-12T09:48:00.001+07:002013-02-28T15:21:17.011+07:00DetailHello all, this is my new blog, my blog is dedicated for my GSLC assignment<br />
<br />
My name is Ryan Dratama ( 1601211571 ), with my lecturer, Daniel Nugraha ( D4748 )<br />
course code : T0604 and my class is 01 PCTAnonymoushttp://www.blogger.com/profile/04197929349836565922noreply@blogger.com0