Am Mittwoch, 23. Mai 2007 04:05 schrieb Patrick R. Michaud:
> Here's the perl 6 code:
>
>     my $a = sub { ... };      # $a is a subroutine reference
>     my $b := $a;
>     # ...;
>     $a = 4;                   # $a is now an Int
>
> How to do the above in PIR if we can't morph a Sub?

I may be not totally uptodate with the recent implementation changes. But I've 
repeatedly urged a clear separation between variables and values. Obviously 
the mixture of these is still the current way to go. Anyway: I'd translate 
above code to the following pseudocode:

  .var '$a' = .value '.sub ... '
  .var '$b' = .var '$a'
  .var '$a' = .value '4'

There is no need for any morph or such operation. Sometimes the implementation 
needs an additional indirection though, but there are already a lot of these 
indirections (think of the pmc_ext or even data pointers in the PMC). 

All values can be shared and are readonly, well, variables are changing. Thx 
to listening.

leo

Reply via email to