change the visit function structure to visit more flexibly
add procedure definition scope and with_new_scope() helper

with_new_scope() helper introduces passed scope and ensures to restore
the old scope