At 18:43 -0500 2000/10/02, David L. Nicol wrote:
>Hmm.  C<no scope> could be implemented in terms of the rfc 340 C<with> like
>so:
>
>   $scope_out_here = with;
>   if ($ints) {
>      with $scope_out_here {use integer}
>   };
>
>C<caller> is about subroutine calls.

Interesting!  I have a few questions (meandering thoughts) though <g>

The example in the RFC gives:

     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


This implies that &A is now something akin to a closure, correct? 
That is to say, the meaning of C<my $A> becomes changed by the 
presence of C<return with;> so that $A is something in between a 
lexical scoped to &A and a lexical scoped around &A ({ my $A; sub A 
{} }).  $A is held in existence by the presence of the context 
object.  Presumably $A would 'go out of scope' and be destroyed at 
the same time as the associated context object?  This worries me, but 
I admit it's neat ;)

What is more worrying to me is this: with a C<no scope;> pragma, you 
can only go up /your/ scope.  Consider this:

     package Nasty;
     my $context;
     {
         package Unsuspecting_Package;
         $context = with;
     }
     use integer with $context;

Spooky action at a distance to be sure!  Also, integer (and others) 
is a compile time issue.  Using C<no scope> can be easily (it would 
appear) implemented for compile-time since it's merely another 
pragma.  On the other hand, C<with> strikes me as more of a run-time 
beast.  (at this point, I'm not sure if I have any idea of what I'm 
talking about, so excuse me if this has digressed into rambling :)

So I like the idea of C<with>, but am not sure it is compeltely 
suitable for invoking pragmata such as integer.

.greg
-- 
"Push to test."
<click>
"Release to detonate."

Reply via email to