`[<<][meta][>>][..]`
Tue Oct 25 15:30:23 EDT 2011

## TML Code in terms of Expr

```This needs a cleanup of Expr.  I currently do not have a way to
represent a variable reference as a term of Expr.

Then I'm not getting the CPS version of makeVar.

Time to take a sneak peak.  It defines the following form:

let retN a =
fun s k -> .<let z = .~a in .~(k s .<z>.)>.

The trick is that this manipulates the return value of the final CPS
expression.

With this change I'm having trouble trying to separate Expr and Term,
so let's merge them.

These work:

makeVar :: TypeOf (Code t) => (Code t) -> MCode (Code t)
makeVar term@(Code sterm) = SC c where
c (State n) k =
Let var sterm (k state' ref) where
state' = State \$ n+1
ref = Code \$ Ref \$ var
var = Var typ nam 0
typ = typeOf term
nam = regPrefix ++ (show \$ n)

runMCode :: MCode rt -> (State -> rt -> Term) -> Term
runMCode (SC c) = c (State 0)

termExpr m = runMCode m k where
k _ (Code (Ref v)) = Ret v  -- toplevel continuation

l = lit 123
l :: TML m r => r Tint

> termExpr \$ add l l

Let (Var i "t0" 0)
(Op i "add" [Lit i "123",
Lit i "123"])
(Ret (Var i "t0" 0))

However, the termFun compiler seems to need some tinkering.  I don't
see immediately how it is different.  It seems most of it can be
reused though.  The result will be a FunDef node.

Maybe it should be a Lambda node.

 http://www.cs.rice.edu/~taha/publications/conference/pepm06.ps

```
`[Reply][About]`
`[<<][meta][>>][..]`
{"ft_lang_label":"__label__en","ft_lang_prob":0.77791286,"math_prob":0.9498948,"size":1416,"snap":"2020-10-2020-16","text_gpt3_token_len":461,"char_repetition_ratio":0.08711048,"word_repetition_ratio":0.0,"special_character_ratio":0.34675142,"punctuation_ratio":0.12828948,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9915505,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-02-18T02:16:17Z\",\"WARC-Record-ID\":\"<urn:uuid:9d21c570-fb22-45c3-a092-35e016644baa>\",\"Content-Length\":\"3024\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:2e81cb9a-5078-41df-b1e3-aedd21dfca2d>\",\"WARC-Concurrent-To\":\"<urn:uuid:525459a0-375d-4947-ac6b-3f9f6798e6d0>\",\"WARC-IP-Address\":\"5.39.77.149\",\"WARC-Target-URI\":\"http://zwizwa.be/-/meta/20111025-153023\",\"WARC-Payload-Digest\":\"sha1:KG6NL3UCUEVUYC5SY4K7RFYA5UOUJP2J\",\"WARC-Block-Digest\":\"sha1:2UBCN5AWC6TKDDACDQLBIFBF7JZNVGFN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-10/CC-MAIN-2020-10_segments_1581875143455.25_warc_CC-MAIN-20200217235417-20200218025417-00126.warc.gz\"}"}