Skip to content

Instantly share code, notes, and snippets.

@zofrex
Last active April 2, 2016 17:22
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 zofrex/66c7fde5114c5747277c94e15d3ff4dd to your computer and use it in GitHub Desktop.
Save zofrex/66c7fde5114c5747277c94e15d3ff4dd to your computer and use it in GitHub Desktop.
proc is_admin {
user_id
} {
switch $user_id {
1 -
3 -
5 { return true }
default { return false }
}
}
rename if if_old
proc if {
condition
block
} {
if_old {$condition == {[is_admin $user_id]}} {
upvar user_id user_id
if_old {$user_id == 22157} {
uplevel 1 $block
}
} else {
set result [uplevel 1 expr $condition]
if_old {$result} {
uplevel 1 $block
}
}
}
set user_id 22157
if {[is_admin $user_id]} {
puts "$user_id is an admin and can do admin things"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment