[33089] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4365 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 6 14:09:14 2015

Date: Fri, 6 Feb 2015 11:09:02 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 6 Feb 2015     Volume: 11 Number: 4365

Today's topics:
    Re: Am I adding an unnecessary step? <rweikusat@mobileactivedefense.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 06 Feb 2015 17:34:57 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Am I adding an unnecessary step?
Message-Id: <874mqzhrjy.fsf@doppelsaurus.mobileactivedefense.com>

"Peter J. Holzer" <hjp-usenet3@hjp.at> writes:
> On 2015-02-04 08:12, Mart van de Wege <mvdwege@gmail.com> wrote:
>> Rainer Weikusat <rweikusat@mobileactivedefense.com> writes:
>>>> Arrays and references are definitely one of Perl's legitimate ugly
>>>> warts.
>>>
>>> I've read this about references a couple of times already, but only ever
>>> as unsubstantiated assertion

[...]

>> I'm none of those. I have no problem with references per se, but the way
>> they interact with, for example, arrays, as in you *need* reference
>> syntax to even do multidimensional arrays,
>
> No, you don't. You can write stuff like 
>
> $a[0][1] = 2;
>
> There is a reference involved, but no "reference syntax".
>
> OTOH, you do need reference syntax even for passing one-dimensional
> arrays to a function. Because of list-flattening, you can't write
>
>     sub foo {
>         my (@a, @b) = @_;
>         
>         ... $a[$i] ... $b[$j] ...
>     }
>
>     foo(@x, @y);
>
> You need to explicitely pass references to arrays:
>
>     sub foo {
>         my ($a, $b) = @_;
>         
>         ... $a->[$i] ... $b->[$j] ...
>     }
>
>     foo(\@x, \@y);

[...]

That it is possible to use a real array as first-level branch
table in such a construct is sort-of a moot point because whole
conglomerate can only be passed around by using a reference to
that and 'reference syntax' has to be used to do anything with it then
(which necessitates understanding the concept in the first place).

(
There's another sort-of involved here: Provided not more than one
arrays has to be passed to a subroutine, @_ can serve in place of that
as the actual scalars making up the array will be on the stack:

---------
my @wart = ([0, 1], [2, 3], [4, 5]);

sub children_of_wart
{
    $_[0][1],  $_[1][1],  ++$_[2][1];
}

print(map{ $_, "\n" } children_of_wart(@wart));
print($wart[2][1], "\n");
---------
)

In contrast to this, Java (according to its documentation) always passes
everything which is not a primitive type by reference and only ever
stores references to it. Because of this, no special syntax for
accessing objectes referred to by reference is necessary and users of
the language can blissfully ignore the distinction between 'direct' and
'indirect' in this respect.

[...]

>> It is true that a lot of complaints are echo-chamber rantings, but
>> that's no reason to go the other way and deny that Perl5 has any warts
>> at all.
>
> Oh, Perl5 has plenty of warts. It's just that one person's wart is
> another person's beauty mark.

Aesthetically, Perl is a wart which formed after Digital guys infected
UNIX(*) and LISP is a palm tree growing out of an IBM mainframe. But
that's a crazy way to look at a programming language: It's useful. It
could be improved in some areas (although presently, I can't name any
which don't really belong to the next category) and it could also be
shuffled around so that some things which used to be on the left are now
on the right and vice-versa. It would then be useful in a different way.


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 4365
***************************************


home help back first fref pref prev next nref lref last post