[pm-h] Interesting Blog Posts on Context & Array vs List

B. Estrade estrabd at gmail.com
Fri Feb 21 07:05:03 PST 2014


So I guess with the signatures, the answer is "it depends" since it'll work
with signatures as one might expect (i.e., the flattened array would have
to have each element correspond to a sig parameter) or the sig parameter
may very well be data type passed by reference.

I read up on the signature thing, and I doubt I'll find it useful for
anything. It's also experimental, so requires an explicit feature 'use' and
can be taken out at any time.

http://search.cpan.org/~tonyc/perl-5.19.9/pod/perlsub.pod#Signatures

It seems a squishy and a little general, maybe it'd be better if one could
specific the Perl data type (scalar, hashref, arrayref, etc) via the
signature definition.

Brett


On Fri, Feb 21, 2014 at 8:03 AM, Uri Guttman <uri at stemsystems.com> wrote:

> On 02/21/2014 08:13 AM, B. Estrade wrote:
>
>> On Wed, Feb 19, 2014 at 2:35 PM, Mark Allen <mrallen1 at yahoo.com> wrote:
>>
>>  When subroutine signatures are released in 5.20, you'll be able to do
>>>
>>> sub foo ($self, $foo, $bar, $baz) {
>>>     $foo ||= 'default';
>>>     $baz //= 0;
>>>
>>>     ...;
>>> }
>>>
>>> Yay!
>>>
>>>
>>
>> How will this behave if you call the method with foo(@a, at b, at c, at d) versus
>> foo(\@a,\@b,\@c,\@d) ?  Does list flattening still occur in this case
>> necessitating the use array references if you want to pass one array per
>> parameter?
>>
>>
> sub calls always flatten into @_. the only way to pass individual arrays
> is by reference. prototypes (not recommended in most cases) do allow arrays
> to be parsed as single args but they are actually passed as references.
>
>
> uri
>
>
> --
> Uri Guttman - The Perl Hunter
> The Best Perl Jobs, The Best Perl Hackers
> http://PerlHunter.com
> _______________________________________________
> Houston mailing list
> Houston at pm.org
> http://mail.pm.org/mailman/listinfo/houston
> Website: http://houston.pm.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/mailman/private/houston/attachments/20140221/0f5ddfd0/attachment-0001.html>


More information about the Houston mailing list