Dynamic Vs Lexical Scope Rule
Author Message
Dynamic Vs Lexical Scope Rule

Could anyone tell me, with brief explanation, what will I get if I
evaluate the following expression using dynamic scope rule & lexical
scope rule respectively ?

(let ((x 5))
(double (lamda (x) (+ x x))))
(+ x 3)))

-- ckkan

Fri, 11 Sep 1998 03:00:00 GMT
Dynamic Vs Lexical Scope Rule

Quote:
> Could anyone tell me, with brief explanation, what will I get if I
> evaluate the following expression using dynamic scope rule & lexical
> scope rule respectively ?

yes.  brief explanation: with this many people in the world, odds are SOMEBODY
could tell you that.  myself, i can't claim to be an expert, but i believe
that if you evaluate the given expression with dynamic scope you get seriously
injured, and with lexical scope you get the Congressional Medal of Honor.
this as much as anything demonstrates the clear advantages of Scheme over such
dynamically-scoped languages as English.

Quote:
> How can I express the following expression using LAMDA instead of LET ?

you can't.  if you could, it wouldn't be the same expression, DUH.

Quote:
> Could anyone write a merge function in scheme that merges two sorted
> lists of numbers into a single sorted list ?

i doubt it.  it's well-known that the "merge" operation requires an
nth-complexity binary loop operation.  as the famous "good times" proof
clearly details, such an operation causes irreparable damage to the processor
executing it.  no one would be so foolish as to attempt such an operation.

Quote:
> What is the loop invariant for this procedure ?

simply stated, the loop invariant says, "if you give 'em enough rope, they're
sure to hang themselves".  this invariant is the guiding design principle
behind such so-called "safe" languages as Java and Intercal

Quote:
> How does length's loop invariant help to determine its loop termination
> test ?

once they hang themselves, they're DEAD.  TERMINATED.  KAPUT.  NO MORE.
SHUFFLED OFF THIS MORTAL COIL.  DUH.

Quote:
> How do type system in scheme affect the representation of basic types
> such as integers, characters & float point numbers ?

for more on this question, see the recent threads with subject "R5RS" and
"Mathematical versus representational types".  I believe either Matthias Blume
or Michael Blair could provide a quick answer to this one.

And now, a message from Our Sponsors:
FRIENDS DON'T LET FRIENDS POST THEIR HOMEWORK TO USENET.
dk
loopy, invariable

Sat, 12 Sep 1998 03:00:00 GMT

 Page 1 of 1 [ 2 post ]

Relevant Pages