Use local. Using your example:
local
local({ V1 = c(1,2,3); V2 = c(1,2,3); P = inner_product(V1, V2); print(P);})# the variable V1, V2, P are undefined here!
You can create a new environment where your variable can be defined; this is how the local scope within a function is defined.
environment
You can read more about this here
check the help for environment as well i.e. type in your R console ?environment
?environment