Add SCOPE function

See http://issue.cc/r3/2119 for details.