RFC 340 (v1) with takes a context

[email protected] (Perl6 RFC Librarian) 29 Sep 2000 01:30:36 -0000
Newsgroups perl.perl6.announce.rfc,perl.perl6.language
Message-ID <[email protected]>
This and other RFCs are available on the web at
  http://dev.perl.org/rfc/

=head1 TITLE

with takes a context

=head1 VERSION

  Maintainer: David Nicol <[email protected]>
  Date: 28 Sep 2000
  Mailing List: [email protected]
  Number: 340
  Version: 1
  Status: Developing

=head1 ABSTRACT

"call frames" become useful as objects.  The current one is always C<with> with
no argument and you can get into an arbitrary one by using C<with $whatever
BLOCK> in either forward or backward form, like C<if>.


=head1 DESCRIPTION
=item  description by commented example

	sub A{
		my $A = shift;
		return with;
	};

	$context1 = A(3);
	print "$context1";		# something like CONTEXT(0XF0GD0G)
        print "$A" with $context1;	# prints 3
        with $context1{print "$A"};	# same thing


=item coexistence w/ pascal-like with 

The context-access C<with> takes a scalar argument, the pascal-like with takes
a hash.  If the pascal-like with is considered as describing aliases to defined
variables, the two have deep similarities.

=item CONTEXT objects in other contexts

In an array context, one of these CONTEXT things will expand into key-value
pairs if it can.

=item warning about memory leaks

using C<with> to store contexts may adversely affect memory recycling.


=head1 IMPLEMENTATION

Perl5 has the hooks required to do this: the closure stuff.  This proposed
C<with> keyword makes access into such things more explicit.


=head1 REFERENCES

None.