develooper Front page | perl.perl6.announce.rfc | Postings from September 2000

RFC 340 (v1) with takes a context

From:
Perl6 RFC Librarian
Date:
September 28, 2000 18:31
Subject:
RFC 340 (v1) with takes a context
Message ID:
20000929013036.11629.qmail@tmtowtdi.perl.org
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 <perl6rfc@davidnicol.com>
  Date: 28 Sep 2000
  Mailing List: perl6-language@perl.org
  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.




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About