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

