fluid-let

fluid-let (key-value-pairs) (script)
temporarily changes currently visible variables, executes script, restores original values, and returns result of script.

(Inherited from my scheme past.)


proc fluid-let {varlist script} {
  foreach {key val} $varlist {
    dict set backup $key [uplevel set $key]
    uplevel set $key $val
  }
  set result [uplevel $script]
  dict for {key val} $backup {
    uplevel set $key $val
  }
  set result
}

© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z