Context::Handle - A convenient context propagation proxy thingy.


Context-Handle documentation  | view source Contained in the Context-Handle distribution.

Index


NAME

Top

Context::Handle - A convenient context propagation proxy thingy.

SYNOPSIS

Top

	use Context::Handle qw/context_sensitive/;

	sub wrapping {
		my $rv = context_sensitive {
			$some_thing->method(); # anything really
		};

		# you can do anything here

		$rv->return; # returns the value in the right context

		# not reached
	}

DESCRIPTION

Top

This module lets you delegate to another method and return the value without caring about context propagation.

The level of support is tied to what Want does - this module tries to make all the distinctions Want can make fully supported, for example array dereference context, boolean context, etc.

EXPORTS

Top

Nothing is exported by default.

context_sensitive BLOCK

This is a convenience shortcut that calls new

METHODS

Top

Regular Usage

new $code

This method invokes $code in the calling sub's context, and returns an object that saves the return value.

rv_container

This instance method returns the return value container object. The only useful methods for the RV containers is value, which has a delegator anyway.

value

This returns the value from the rv_container

return

This (ab)uses Want to perform a double return.

Saying

	$rv->return;

is just like

	return $rv->value;

Introspection

Incidientially due to the needs of the wrapping layer this module also provides an OO interface to Want, more or less ;-)

bool
void
scalar
list
refarray
refhash
refscalar
refobject
refcode
refglob

All of these methods return boolean values, with respect to the

TODO

Top

ACKNOWLEGMENTS

Top

Robin Houston for Want and lots of help by email

AUTHOR

Top

Yuval Kogman <nothingmuch@woobling.org>

COPYRIGHT & LICENSE

Top


Context-Handle documentation  | view source Contained in the Context-Handle distribution.