Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Need second advice concerning scope exercice

Name: Anonymous 2009-10-26 19:45

Lets say you have the following expression: (in a syntax identical to haskell)

let x = 5 in
let f1 x y = x + y in
let f2 x y = f1 y x in
f2 7 13

what is the result if the scope is dynamic? static?
i think that with dynamic, the result is 10
and static is 20

is this correct?

Name: Anonymous 2009-10-26 19:56

It doesn't matter if the scope is dynamic of static in that case, because you're only referencing arguments, not externally defined variables.

Name: Anonymous 2009-10-26 20:29


konnchiwa-!! ¬o( ̄- ̄メ)

im a 15 year old gyangusutaa (gangsta) that likes to atsumaru (collect) Pakistan-quality buki (weapons and shit), gyangusutaa rappu (gangsta rap), and the shii uooku (c step). i am in a gyangu cheemu (gang) and deal shyabu (drugs) at my koukou (high school). ore (I) can korosu (kill) kiisan (you) yaritakattara (if i wanted to).

Name: Anonymous 2009-10-26 20:30

>>1
I'll help you because my anus is in terrible danger.

Your example does nothing you wouldn't expect. Here's one that does something:

let f = putStrLn in
let putStrLn = const $ return () in -- does nothing; has same type as putStrLn
f "This won't print"


The difference between lexical and dynamic scope is that lexical scope searches f's definition context when looking up putStrLn, whereas dynamic scope searches the call site. Function arguments actually behave exactly the same way in both cases, because they're introduced in the innermost scope.

Name: Anonymous 2009-10-26 20:48

so in both cases the output is 20?

Name: Anonymous 2009-10-27 1:42

>>5
Yep.

Name: Anonymous 2009-10-27 7:13

why the hell don't you just type it in and find out?

Name: Anonymous 2010-12-17 1:34

Erika once told me that Xarn is a bad boyfriend

Name: Anonymous 2011-01-31 19:53

<-- check em dubz

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List