With a slight modification of your code:
x <- 10
get1 <- x
get2 <- (function() x)()
# or equivalently:
# fun <- function() x
# get2 <- fun()
... there is no difference, exactly the same value is used. That is, identical(get1, get2) equals TRUE. In get2 we used an anonymous function, x is neither defined within the function nor given as an argument, so it is taken from the parent environment. get1 gets the value of x in a more straightforward way but when the assignment is done, that doesn't matter any more.
On the other hand, of course, functions have environments, so if you have time and you're not afraid of some waste of effort, you can do things like:
`environment<-`(function() x, new.env())()
# Error in `environment<-`(function() x, new.env())() :
# object 'x' not found
# notice that a more conventional way to achieve the above is ...
# foo <- function() x
# environment(foo) <- new.env()
# foo()
x not found! Where did x go? Nowhere, we just didn't find it as it was not in the search path.
`environment<-`(function() x, new.env(parent=environment()))()
# 10
# so x was found!
# the anon. function's environment is new.env, with .GlobalEnv as parent
# as x is not found int an empty new.env, it is searched for in .GlobalEnv
So what? This can actually make a practical difference. Or at least, this can help one understand how environments work. Consider the following example:
m1 <- mean(1:5)
# m1 == 3
m2 <- function() mean(1:5)
m2()
# 3
environment(m2) <- new.env()
m2()
# still 3
environment(m2) <- emptyenv()
m2()
# Error in m2() : could not find function "mean"
m2 <- function() 3+2
m2()
# [1] 5
environment(m2) <- emptyenv()
m2()
# Error in m2() : could not find function "+"
So names like mean or even + are variables whose values (the functions) have to be found somehow. They are usually there in the parent environments of the function's environment but we can remove this using environmnent(fun) <- emptyenv().
So what's the point so far? There are many but the most important one is it is a good practice to avoid functions "grabbing" some values from the global environment. That is, instead of:
fun <- function() x
fun()
# [1] 10
... it is a better idea to use arguments for any "input data" you want to give to a function:
fun <- function(x) x
fun(x)
# [1] 10
fun(2) # equivalent to fun(x=2)
# [1] 2
fun(x+1)
# [1] 11