Skip to content

Instantly share code, notes, and snippets.

@sebres
Created October 17, 2019 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebres/38b6f446158faab1ed12a8a65e80838d to your computer and use it in GitHub Desktop.
Save sebres/38b6f446158faab1ed12a8a65e80838d to your computer and use it in GitHub Desktop.
ldeclare -- multi-line list declaration with simple substitution (and comments)
# -------------------------------------------------------------------------------
# ldeclare -- multi-line list declaration with simple substitution (and comments)
# -------------------------------------------------------------------------------
proc ldeclare l {
uplevel "list [string map [list \n "\\\n"] \
[regsub -all -line {^\s*\#[^\n]*} $l {}]
]"
}
# -------------------------------------------------------------------------------
if 0 {;# ## Usage example :
% set a 5; set b "test test"
% puts [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}
};#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment