Ken Fox wrote:

> IMHO, curries have nothing to do with this. All "with" really does is
> create a dynamic scope from the contents of the hash and evaluate its
> block in that scope.


Right, the "with" people are using ^hats because its an available
operator, just the same way the "curry" people are.  May have shifted
over the weekend I do not know.

 
>   my %person = { name => 'John Doe', age => 47 };
> 
>   with %person {
>      print "$name is $age years old\n";
>   }

How about changing it to 
        print "$\name is $\age years old\n";

That's clear as long as we can't name variables except w/in [\w]


> 
> becomes
> 
>   {
>      my $env = $CORE::CURRENT_SCOPE;
> 
>      while (my($k, $v) = each(%person)) {
>        $env->bind_scalar($k, $v);
>      }
> 
>      print "$name is $age years old\n";
>   }
> 
> Where $CORE::CURRENT_SCOPE is some sort of magical variable that provides
> access to the symbol table for the current scope. The bind_scalar() method
> creates a new value binding. The code block of the "with" is evaluated
> with these new bindings in effect.
> 
> The simplest way of doing this is to turn off warnings inside the "with"
> block and force those variable names into the local scope at compile time.
> Then at run-time the bind_scalar() can re-bind the variables to the values
> in the hash.
> 
> - Ken

But that doesn't give us the speed win we want from compiling offset lookups
into a static record structure, at the cost of some funny "in -the-record"
syntax, as in other languages that support this (pascal, VB, C)




-- 
                          David Nicol 816.235.1187 [EMAIL PROTECTED]

Reply via email to