Posted to tcl by sebres at Thu Oct 17 21:57:46 GMT 2019view pretty

proc ldeclare l { 
  uplevel "list [string map [list \n "\\\n"] \
    [regsub -all -line {^\s*\#[^\n]*} $l {}]
  ]"
}

% set a 5; set b "test test"
% ldeclare {
  a $a
  b $b
  c [list $a $b]
  # comment:
  d [list $a {*}$b]
}]

a 5 b {test test} c {5 {test test}} d {5 test test}