On Jan 21, 2013, at 2:20 PM, David Richards <lists / ruby-forum.com> =
wrote:
> Does this inconsistency result from a parser-level layer of 'syntactic
> sugar'? I'm also getting a sense that a 'block' is a parser-level
> construct,
> and a 'Proc' is an execution-level object.

I don't think it is stressed enough that a block is a syntactic =
structure
that is *always* part of a method call.

When a method executes, the block associated with the method call can
be executed implicitly via the 'yield' keyword, or explicitly reified
into a Proc object.  Once captured within an Proc object it can be =
executed
via the #call or #[] methods on the object (which are instance methods =
of
the Proc class).

The reification (or capture) can be triggered via the block argument in
a formal argument list:

	def foo(arg0, &block)
	  yield("arg to the block)	# call implicit block
	  block.call("arg to block")    # call same block via Proc#call =
instance method
	  block["arg to block"]         # call same block via Proc#[] =
instance method
	end

or the reification can be triggered on demand:

	def foo(arg0)
	  if some_condition)
            captured =3D Proc.new		# Proc.new without =
explicit block captures current implicit block
          else
            yield("arg to block")  # call implicit block
          end
        end


Proc objects can also be created via the Kernel#proc method call:

	addition =3D         proc { |a,b| a + b }
	multiplication =3D   proc { |c,d| c * d }

	puts addition.call(1,2)         # =3D> 3
	puts multiplication.call(2,10)  # =3D> 20

In these examples, the blocks are syntactically part of the calls to to =
the proc method.

	puts addition.class             # =3D> Proc
	puts multiplication.class       # =3D> Proc


Gary Wright=