[32225] in Perl-Users-Digest
Perl-Users Digest, Issue: 3490 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 4 09:09:41 2011
Date: Sun, 4 Sep 2011 06:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 4 Sep 2011 Volume: 11 Number: 3490
Today's topics:
Re: What to return in scalar context ? <nospam-abuse@ilyaz.org>
Re: Why does sort return undef in scalar context ? <nospam-abuse@ilyaz.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 4 Sep 2011 09:15:47 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: What to return in scalar context ?
Message-Id: <slrnj66ge3.cv1.nospam-abuse@panda.math.berkeley.edu>
On 2011-09-02, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
> either. Please stop trying to say "the scalar value of a list is its
> length". It's actually more often *not* true rather than true, as my
> perlmonks post shows: http://www.perlmonks.org/?node_id=347416
I suspect that the main heat of this discussion comes of from
(objectively confusing) clash of two DIFFERENT meanings of the word
LIST in discussions of Perl language.
a) LIST CONTEXT is the "opposite of scalar context";
b) and there is a LIST CONSTRUCTION (more or less comma operator).
The List construction may be put in two different (actually, three ;-)
contexts. It behaves differently in these contexts.
The list context appears only in (surprise!) one context. One
concludes that the behaviour of the list operator in scalar/list
context SHOULD NOT have a direct relation to how context switches the
meaning of the operator.
[This is pure logic, so not directly applicable to any real-life
situation ;-). However, an experiment with Perl docs at hand would
immediately confirm this.]
===== The principal question
If an operator is primarily designed to work in list context and
return X, what is the MOST LOGICAL thing to return in scalar context
===== The conventional answer
If there are SEVERAL things which may be all EXPECTED to be "logically
deducible" (possibly by DIFFERENT PEOPLE) - it was decided to be an
"unwanted situation". This is called "the principle of least surprise".
[Perl is not very "logical"; one needs to MEMORIZE a lot of stuff.
So if adding a certain USEFUL feature would force people to
memorize MORE, a benefit should be weighted against the added problem.]
Hope this helps,
Ilya
------------------------------
Date: Sun, 4 Sep 2011 09:21:04 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Why does sort return undef in scalar context ?
Message-Id: <slrnj66go0.cv1.nospam-abuse@panda.math.berkeley.edu>
On 2011-09-02, Rainer Weikusat <rweikusat@mssgmbh.com> wrote:
> In order to be able to get anywhere here, it is first necessary to
> have something which compiles a file with C source code such that it
> will be compatible with perl. The following shellscript can be used
> for that:
IMO, the simplest way to experiment with C-to-Perl interface is
a) Use h2xs with appropriate options to generate an "empty" XSUB
module named FOO;
b) Add some XSUB directives to the end of FOO/FOO.xs and testing
code to FOO/t/FOO.t;
c) run
Makefile.PL
make test
in ./FOO.
(Or at least it was the simplest way 15 years ago. Is there a simpler
way now?)
Hope this helps,
Ilya
------------------------------
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 3490
***************************************