On Sun, 17 Aug 2003, Benjamin Goldberg wrote:

> Michal Wallace wrote:
>
> > Uh-oh. I just went to implement "del x"
> > and there's no op to remove a variable
> > from a lexical pad! :)
> 
> Why would you want to remove a variable from a lexical pad?
> 
> Surely the "right thing to do" would be to create a new pad (scope),
> then add your 'x' variable which you plan to 'delete' in the future,
> then when you want to delete that variable, pop off that pad.


Hmm. Do you mean

  if for stmt in block:
     if stmt.type == undef:
        flag_as_going_to_delet(stmt.varname)

So I can create a new pad when it's assigned?
It can't be a simple pop though, can it?

    #!/usr/bin/perl
    $x = "cat";
    $y = "pop $x?";
    undef $x;
    print "x = $x \n";
    print "y = $y \n";

Because here, $x has to be defined before $y, so
I'd have to delete the -2nd scope. Unless the
code was smart enough to work out that y is in
-2 and x is in -1... 

In any case, what does it buy me? it seems like a 
lot of work when there's already a delete_keyed 
op, and leo just made an implementation for pads. :)

I guess in perl it's not bad, since that's the
whole point of undef, you can just $x = PerlUndef
it... But in python, this throws a NameError:

   x = 1
   del x 
   x

So the easiest thing to me is just to translate 
del x as  "remove this from the current pad". 

Sincerely,
 
Michal J Wallace
Sabren Enterprises, Inc.
-------------------------------------
contact: [EMAIL PROTECTED]
hosting: http://www.cornerhost.com/
my site: http://www.withoutane.com/
--------------------------------------


Reply via email to