H = { } --setmetatable(H, H)
H.__index=H
-H.template = { }
+H.template = { alpha = { } }
--------------------------------------------------------------------------------
--
-- free_vars is an old_name -> new_name dictionary computed from alpha:
-- self.alpha is not an efficient representation for searching.
- if not alpha or #alpha==0 then alpha = `Local{ { }, { } }; self.alpha=alpha end
+ if not alpha then alpha = { }; self.alpha = alpha end
+ if #alpha==0 then alpha <- `Local{ { }, { } } end
local new, old = unpack(alpha)
local free_vars = { }
-{ block:
-{ extension 'log' }
-{ extension 'H' }
+
require 'dollar'
+
+ local H = H:new{alpha={ }}
+ print("initial H.alpha", H.alpha)
+
+
function dollar.Q(cond, iftrue, iffalse)
local b = +{ block:
local v
- print("ternary cond")
- if -{!cond} then v = -{!iftrue}
+ if -{!cond} then v = -{!iftrue}
else v = -{!iffalse} end }
local r = `Stat{ b, +{v} }
- $log('before hygiene:', H.alpha)
H(r)
- $log('after hygiene:', H.alpha)
return r
- end }
+ end
+
+ $log(H)
+ return H.alpha }
-y=$Q(x==1, a, b)
\ No newline at end of file
+x=1 ; y=$Q(x==1, 'one', 'two') ; print(y)
+x=2 ; y=$Q(x==1, 'one', 'two') ; print(y)
\ No newline at end of file