delay                  package:base                  R Documentation

_D_e_l_a_y _E_v_a_l_u_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     'delay' creates a _promise_ to evaluate the given expression in
     the specified environment if its value is requested. This provides
     direct access to _lazy evaluation_ mechanism used by R for the
     evaluation of (interpreted) functions.

_U_s_a_g_e:

     delay(x, env=.GlobalEnv)

_A_r_g_u_m_e_n_t_s:

       x: an expression.

     env: an evaluation environment

_D_e_t_a_i_l_s:

     This is an experimental feature and its addition is purely for
     evaluation purposes.

_V_a_l_u_e:

     A _promise_ to evaluate the expression. The value which is
     returned by 'delay' can be assigned without forcing its
     evaluation, but any further accesses will cause evaluation.

_E_x_a_m_p_l_e_s:

     x <- delay({
         for(i in 1:7)
             cat("yippee!\n")
         10
     })

     x^2 #- yippee
     x^2 #- simple number

