[Haskell-cafe] Re: Is curryfication practical with dynamic scope?

Loup Vaillant loup.vaillant at gmail.com
Sun Apr 26 17:00:47 EDT 2009


Well, 2 things: first, I meant "currying". second, I found the answer: no.
Under dynamic typing, the reduction steps are:

(\a -> \b -> a) 1 2
(\b -> a) 2 -- the substitution don't occur right away (that would be
lexical scope)
a
?? "a" is not in the environment!!

Sorry for the noise.

PS: In a meta interpreter, lexical scope seems to be actually easier
to implement than dynamic scope.

2009/4/26 Loup Vaillant <loup.vaillant at gmail.com>:
> Hi, can this code
>
> (\a -> \b -> a) 1 2
>
> eval to normal form in a strict language with dynamic scope?
>
> Thanks,
> Loup
>
>
> PS: some context:
>
> I am currently implementing a toy language. The AST is this one:
>
> data whnf = -- Weak Head Normal Form
>  | Unit
>  | Int  of int
>  | Bool of bool
>  | Prim of (whnf -> whnf)  -- curried
>  | Fun  of string * expr   -- curried
>
> data expr =
>  | Whnf of whnf
>  | Var  of string
>  | App  of expr * expr
>  | If   of expr * expr * expr
>
> Dynamic typing, dynamic scope, and, as you can see, functions have to
> be curried. I plan to implement lexical scope.
>


More information about the Haskell-Cafe mailing list