STG to JavaScript translation

Stefan O'Rear stefanor at
Wed Sep 19 22:27:01 EDT 2007

On Thu, Sep 20, 2007 at 06:13:38AM +0400, Victor Nazarov wrote:
> I still have some questions regarding the GHC internals.
> There is a description of STG language in the "Making a Fast Curry:
> Push/Enter vs. Eval/Apply for Higher-oder Languages" (2004) by Simon
> Marlow and Simon Peyton Jones paper. In this description the
> constructor application (CONS closure) can only appear on the right
> hand side of the bindings. This is totally reasonable if "let" is the
> only construct that allocates objects. But in the GHC's StgSyn.hs any
> expression can be constructor application. How does constructor
> applications are compiled? Are they implicitly transformed to let?
> For example:
> f =
>   let g = (THUNK h x)
>   in (CONS g y)
> Is this exactly the same as (right variant following the paper)
> f =
>   let g = (THUNK h x)
>   in let freshvar = (CONS g y)
>       in freshvar
> ?
> And the second question is how does constructor tag is passed to case
> when non-vector return is used? In register? In constructor closure?
> Are there any cases when closure is not build for constructor
> application? What the case binder is bound to if there is no closure
> for constructor application?

The StgSyn type *declaration* allows this stuff.  In actual use, it's
always kept in, and expected to be in, A-normal form.  The Simons have
said that much of GHC is sadly written as though it was written in a
dynamically typed language and then shoddily ported to Haskell; types do
NOT describe ghc's data, to borrow one of Conor's catchphrases.

(I can't find the original)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url :

More information about the Glasgow-haskell-users mailing list