[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: Benchmarking (was: Re: [MacPerl] crazy hoops to do something that seems so simple?)



pudge@pobox.com (Chris Nandor) wrote:
>At 12:47 -0500 2000.11.15, Scott R. Godin wrote:
>>ahhhhhhh ok.. so um.. why is there no \ reference to the sub then?
>>
>>such as my $trans = \&sub whatever {#content};
>>
>>is that implicit in the eval?
>
>Two primary ways to create a reference to a function:
>1. Anonymous sub:
>    $ref = sub { ... };
>
>2. Named sub:
>    $ref = \&somesub;
>
>Ronald chose the first one, since there was no named sub to create a
>reference to, as in the second one.


It's exactly analogous to creating references to other Perl structures like
hashes or arrays.

     Two primary ways to create a reference to a hash:
     1. Anonymous:
        $ref = { ... };

     2. Named:
        $ref = \%somehash;


     Two primary ways to create a reference to an array:
     1. Anonymous:
        $ref = [ ... ];

     2. Named:
        $ref = \@somearray;

A reference points to some other thingy (internal structure) that may be
a hash, array, subroutine, or whatever.  That thingy may or may not also
be reachable by traditional names like %somehash, @somearray, or
&somesub.


  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org