I'm learning about lazy functional language evaluation and came across the STG machine. In order to understand it I'm building a small toy compiler for a functional language (to STG).
However there's one thing I can't really wrap my head around: according to the 1992 paper, an stg expression is either: a let
binding, a case
expression, an application, a constructor, a built-in operation or an unboxed literal.
Therefore if I have a program which just uses a variable, not invokes it, it must still compile to an application, because there's no "var" option in the stg expression variants (page 20 in the paper). For example:
id x = x
compiles to
id = {} \ {x} -> x {} # application with no arguments
But, what if this id
function expects a primitive value? (id :: Int# -> Int#
)
It can't compile to an application, because you can't "enter" a primitive value, but there's no other option?
Thanks very much
(Edit: link to the paper I'm referring to)