[33055] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4331 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 18 03:09:19 2014

Date: Thu, 18 Dec 2014 00:09:05 -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           Thu, 18 Dec 2014     Volume: 11 Number: 4331

Today's topics:
    Re: Both substitute and filter (Seymour J.)
    Re: Both substitute and filter <stevem_@nogood.com>
    Re: Both substitute and filter <gravitalsun@hotmail.foo>
    Re: Both substitute and filter <m@rtij.nl.invlalid>
    Re: Both substitute and filter <rweikusat@mobileactivedefense.com>
    Re: Both substitute and filter <bauhaus@futureapps.invalid>
    Re: Both substitute and filter <jblack@nospam.com>
    Re: Both substitute and filter <rweikusat@mobileactivedefense.com>
    Re: Both substitute and filter <bauhaus@futureapps.invalid>
    Re: Both substitute and filter <hjp-usenet3@hjp.at>
    Re: Both substitute and filter <rweikusat@mobileactivedefense.com>
    Re: Both substitute and filter <stevem_@nogood.com>
    Re: Both substitute and filter <stevem_@nogood.com>
    Re: Both substitute and filter <jblack@nospam.com>
    Re: Both substitute and filter <derykus@gmail.com>
    Re: Both substitute and filter <stevem_@nogood.com>
    Re: Both substitute and filter <stevem_@nogood.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 17 Dec 2014 09:30:17 -0500
From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
Subject: Re: Both substitute and filter
Message-Id: <54919379$6$fuzhry+tra$mr2ice@news.patriot.net>

In <yD8kw.352459$W25.293766@fx02.iad>, on 12/16/2014
   at 09:36 PM, Steve May <stevem_@nogood.com> said:

>Not specific to the use of  my @array = (); 

And not even relevant to it. The use of extraneous initialization is
not remotely similar to the use of meaningful variable names.

>The point being that (for me) I find it easier

Others have already said that they find it harder to read code that
has extraneous initialization.

>execution time

And in readability. An author is rarely the best judge of how readable
his output is; that's why you need an outside reviewer.

>In my book, the simplest easiest code is the best code.

Yet the code you defend is more complicated and harder.

>Might even approach elegance. :-)

"but what you strip away."

>Surprisingly, Ranier didn't mention the execution speed hit for 
>needlessly assigning an empty array though there _is_ one 
>according to my testing.

Presumably because the hit to simplicity is more significant than the
hit to performance.

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org



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

Date: Wed, 17 Dec 2014 10:56:10 -0800
From: Steve May <stevem_@nogood.com>
Subject: Re: Both substitute and filter
Message-Id: <glkkw.927705$FX2.175120@fx18.iad>

On 12/17/2014 07:32 AM, Rainer Weikusat wrote:
> Georg Bauhaus <bauhaus@futureapps.invalid> writes:
>> On 16.12.14 16:26, Rainer Weikusat wrote:

> my @leaky_bucked = ();
>
> the assignment is obviously useless to anyone who understands the code
> and a gratuitious burden to understanding ("Finally figured it out!
> It's useless!") to everybody else. Because of this, it shouldn't exist
> to begin with.
>

An honest question: would you really spend more than an eye blink 
understanding

my @leaky_bucket = ();

I truly want to know.  I wouldn't find it remarkable in any way since I 
use it all the time, but....

tia,

\s


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

Date: Wed, 17 Dec 2014 22:50:35 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Both substitute and filter
Message-Id: <m6sqb3$1t8u$1@news.ntua.gr>

>> /^TARGET(.*)$(?{print "$^N\n"})/ for  qw/hi there TARGET23 hello
>> TARGETblarg world/
>
> I do believe we have the winner for worst solution.  Can you work in
> an eval somewhere for bonus points?
>


nope that was my 2 cents for you


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

Date: Wed, 17 Dec 2014 22:08:17 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Both substitute and filter
Message-Id: <1v79mb-jsf.ln1@news.rtij.nl>

On Mon, 15 Dec 2014 06:06:06 +0000, Tim McDaniel wrote:

> In article <m6ha5t$1u1h$1@news.ntua.gr>,
> George Mpouras  <gravitalsun@hotmail.foo> wrote:
>>On 13/12/2014 01:49, Tim McDaniel wrote:
>>> @sources = ("hi", "there", "TARGET23", "hello", "TARGETblarg",
>>> "world");
>>> @results = ()
>>> for each member of @sources
>>>      if s/^TARGET// matched
>>>          push onto @results the result of the s///
>>>      else
>>>          do nothing
>>
>>
>>use strict;
>>use warnings;
>>
>>/^TARGET(.*)$(?{print "$^N\n"})/ for  qw/hi there TARGET23 hello
>>TARGETblarg world/
> 
> I do believe we have the winner for worst solution.  Can you work in an
> eval somewhere for bonus points?

Easy.

eval '/^TARGET(.*)$(?{print "$^N\n"})/' for  qw/hi there TARGET23 hello 
TARGETblarg world/

:-)

M4


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

Date: Wed, 17 Dec 2014 21:19:39 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Both substitute and filter
Message-Id: <87oar2ug7n.fsf@doppelsaurus.mobileactivedefense.com>

Steve May <stevem_@nogood.com> writes:
> On 12/17/2014 07:32 AM, Rainer Weikusat wrote:
>> Georg Bauhaus <bauhaus@futureapps.invalid> writes:
>>> On 16.12.14 16:26, Rainer Weikusat wrote:
>
>> my @leaky_bucked = ();
>>
>> the assignment is obviously useless to anyone who understands the code
>> and a gratuitious burden to understanding ("Finally figured it out!
>> It's useless!") to everybody else. Because of this, it shouldn't exist
>> to begin with.
>>
>
> An honest question: would you really spend more than an eye blink
> understanding
>
> my @leaky_bucket = ();

One blink for understanding, two for a silent prayer and another two for
deleting the = (). Times the number of variables 'superinitialized' in
this way plus all the blinks of an eye needed to discard all the other
code without technical purpose. A grain of sand is insignificantly
small, yet, enough of them clustered together in one place can result in
a huge dune seriously impeding anyone who has to cross it.

And there are two other aspects:

1. Assuming a somewhat large project multiple people work on in a
   free-style way, each of these people will have his very own set of
   functionless code annotations he always uses because of historical
   reasons only known to him. Since everybody also reuses code written
   by everybody else without ever changing more than what is absolutely
   necessary, this quickly needs to a situation where half of the code
   or more (I'm not making this up) is a wild mix of different kinds of
   things which don't do anything useful and whose theoretical purpose
   nobody understands.

2. People also learn coding by "copy'n'paste and modify carefully".


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

Date: Wed, 17 Dec 2014 22:47:41 +0100
From: Georg Bauhaus <bauhaus@futureapps.invalid>
Subject: Re: Both substitute and filter
Message-Id: <m6stl9$lc8$1@dont-email.me>

On 17.12.14 16:32, Rainer Weikusat wrote:
> Georg Bauhaus <bauhaus@futureapps.invalid> writes:
>> On 16.12.14 16:26, Rainer Weikusat wrote:
>>> Considering that @array is obviously (see sigil) neither a
>>> scalar nor a hash of scalars, it must be an array of scalars (of length
>>> 0).
>>
>> By itself, @array is just the name of an array.
>
> By itself, @array is a sequence of graphemes and any meaning which might
> be associated with that depends on a certain context supplying an
> interpretation.

Precisely, interpretation is all that matters. Now, what is the context
in the programming situation?  (I didn't suggest anything other
than what programmers using Perl might think about “@array”.
More below.)

> I suggest that you stop changing the topic of the conversation with
> every sentence as this can only serve to create gratuitious confusion.

Actually, variable names after “my” can only be truly understood,
especially in view of its relatives and variations like ”our” and
“local”, if one forces one's own mind into a Perl interpreter, not
a programmer. Nothing wrong with this at all, except that the
attitude, if dominating, dismisses certain ways of solving problems.
Even at the cost of complexity of (good) explanations of Perl's
variable declarations.

You give your reasons for disliking ”= ()” after object creation,
which is perfectly fine, and perfectly personal as stated, and,
by nature of good reasons, totally reasonable.
You have given formal demonstrations of why you qualify
writing ”= ()" here as wrong. I challenge that "wrong" on the basis
of unnecessary narrowness (narrowing to Perl), useful as it might
be in some narrower circumstances, and on the basis of expressive
style.

There is formal logic at its best, judging programming text from
nothing but the choices of Perl's definition. But these, being
"historic" (and somewhat accidental), do not fare well with how
people do successfully solve their problems in Perl, as we are
being told here! (With or without assignments.)

> People who mistakenly believe that explicit creation of 'package global'
> object was necessary are surely not unreasonably when they - as
> mistakenly - conclude that it ought to be necessary for objects with
> lexically-scoped names, too. But that the lanuage doesn't provide a way
> to do this should eventually cause them to understand that their belief
> was mistaken.

Likewise, logicians could broaden their view towards the
usefulness of redundant uselessness (sic) such as putting
cheap assignments after variable declarations for reasons
of their better understanding (as stated).

Not every professional works best when using the language
"best", and they may annoy specialist who know how to write
the "best" Perl under Perl's formal rule (pun intended):

> the assignment is obviously useless to anyone who understands the code
> and a gratuitious burden to understanding ("Finally figured it out!
> It's useless!") to everybody else.

Are you saying that every Person such that Person understands
the code and does so in the formal Perl sense is actually everybody,
and then everybody finds “= ()” a burden? I don't think so, given
the other statements. (Both meanings.) When "burden" is true only about
those "who understand" (Perl well) and think about the technically
superfluous “= ()”, can they not leniently think beyond Perl?

My view is that understanding code need not stop at the formal
definitions of Perl's “my”, and a general understanding of declarations
in Perl can only temporarily stop at just “my” since declaring
variables is done in more ways.


> 'just more clear' is not a well-defined term.

'just more clear' can well be defined relative to projects'
needs: it might mean that the single author or the reviewers
mentioned by Shmuel Metz have the least problems understanding
that this variable is going to be a list with no value in it.
(Either with, or without assignment.)

That's the people your "usually" could refer to, a word which you
have used without reference and which therefore I couldn't associate.

Repeated use of "obvious" also hints at something that is used
as an unstated reference.

> As above, in
>
> my $xyz = 0;
   there might be a few lines of code here!
> ++$xys;
>
> the = 0 is useless.

“= 0” tells us the kind of the scalar! That's quite a use, I'd say.
$xyz is an int, it's not a string, and not a ref. It has a value,
and we learn all this because of “= 0”. We are now awaiting to see
$xyz used as a number, nothing else. (One could consider “= 1”…)

Not meaningful? Maybe not to Perl, maybe redundant, but so what?
The algorithm stays correct, with or without the assignment.


I'm off for a few days.



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

Date: Wed, 17 Dec 2014 15:59:51 -0600
From: John Black <jblack@nospam.com>
Subject: Re: Both substitute and filter
Message-Id: <MPG.2efbb8cdc0a66ea298980d@news.eternal-september.org>

In article <glkkw.927705$FX2.175120@fx18.iad>, stevem_@nogood.com says...
> 
> On 12/17/2014 07:32 AM, Rainer Weikusat wrote:
> > Georg Bauhaus <bauhaus@futureapps.invalid> writes:
> >> On 16.12.14 16:26, Rainer Weikusat wrote:
> 
> > my @leaky_bucked = ();
> >
> > the assignment is obviously useless to anyone who understands the code
> > and a gratuitious burden to understanding ("Finally figured it out!
> > It's useless!") to everybody else. Because of this, it shouldn't exist
> > to begin with.
> >
> 
> An honest question: would you really spend more than an eye blink 
> understanding
> 
> my @leaky_bucket = ();
> 
> I truly want to know.  I wouldn't find it remarkable in any way since I 
> use it all the time, but....

Exactly.  I can't believe people are still arguing about this.  The code is pefectly clear 
either way so if the coder prefers it, then its fine.  And there is no computer for which the 
execution time difference would be significant or even measurable.  I've seen examples of 
code that could have been made be much more readable (some even from the people complaining 
about = ();) but this is not such an example.  IMO

John Black 


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

Date: Wed, 17 Dec 2014 22:14:17 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Both substitute and filter
Message-Id: <87k31pvs92.fsf@doppelsaurus.mobileactivedefense.com>

John Black <jblack@nospam.com> writes:
> In article <glkkw.927705$FX2.175120@fx18.iad>, stevem_@nogood.com says...
>> 
>> On 12/17/2014 07:32 AM, Rainer Weikusat wrote:
>> > Georg Bauhaus <bauhaus@futureapps.invalid> writes:
>> >> On 16.12.14 16:26, Rainer Weikusat wrote:
>> 
>> > my @leaky_bucked = ();
>> >
>> > the assignment is obviously useless to anyone who understands the code
>> > and a gratuitious burden to understanding ("Finally figured it out!
>> > It's useless!") to everybody else. Because of this, it shouldn't exist
>> > to begin with.
>> >
>> 
>> An honest question: would you really spend more than an eye blink 
>> understanding
>> 
>> my @leaky_bucket = ();
>> 
>> I truly want to know.  I wouldn't find it remarkable in any way since I 
>> use it all the time, but....
>
> Exactly.  I can't believe people are still arguing about this.  The code is pefectly clear 
> either way so if the coder prefers it, then its fine.  And there is no computer for which the 
> execution time difference would be significant or even measurable.

Thank for supplying the usual two justifications for 'useless code'

	- I always do it this way!
	
	- And the machine doesn't complain about it!

The thing is, code isn't solely written for machines but also for other
people.


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

Date: Wed, 17 Dec 2014 23:51:23 +0100
From: Georg Bauhaus <bauhaus@futureapps.invalid>
Subject: Re: Both substitute and filter
Message-Id: <m6t1cn$5l7$1@dont-email.me>

On 17.12.14 23:14, Rainer Weikusat wrote:
> John Black <jblack@nospam.com> writes:

> Thank for supplying the usual two justifications for 'useless code'

That's your usual specimen of clever rhetoric:
The "the" in "the two" is clearly unjustified, as the two statements you then
list have the least to do with justifying assignment after declaration:
They are just the statements claiming that this stylistic preference is
technically harmless. This preference is justified by other statements.

Hence, the two shortened (by you) statements are not the very reason
for adding 'useless code' (as you like to put it); one of them just says
adding something doesn't hurt, technically:

> 	- I always do it this way!
    BECAUSE that helps me/us understand the program!  (That's justification.)
> 	
> 	- And the machine doesn't complain about it!
    (That's why it's fine, no negation of horror vacui is needed.)

> The thing is, code isn't solely written for machines but also for other
> people.

Precisely. Written by and for people like the people arguing here
for either way of expressing ideas. Now we could start



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

Date: Wed, 17 Dec 2014 23:55:50 +0100
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: Both substitute and filter
Message-Id: <slrnm942fm.d5j.hjp-usenet3@hrunkner.hjp.at>

On 2014-12-17 14:30, Shmuel Metz <spamtrap@library.lspace.org.invalid> wrote:
> In <yD8kw.352459$W25.293766@fx02.iad>, on 12/16/2014
>    at 09:36 PM, Steve May <stevem_@nogood.com> said:
>
>>Not specific to the use of  my @array = (); 
>
> And not even relevant to it. The use of extraneous initialization is
> not remotely similar to the use of meaningful variable names.
>
>>The point being that (for me) I find it easier
>
> Others have already said that they find it harder to read code that
> has extraneous initialization.

And others have said that they find it MORE readable.

Can we please stop this childish "Do - don't - do - don't" game?
We repeat that every couple of years and since most of us aren't new
here I doubt we will learn anything new.


>>execution time
>
> And in readability. An author is rarely the best judge of how readable
> his output is; that's why you need an outside reviewer.

For most code, the author is the only or at least the most frequent
reader. As such, he is the best judge, because he is the only relevant
judge.

If you work in a team or publish your code as open source, different
standards apply.

        hp


-- 
   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   | hjp@hjp.at         | die Satzbestandteile des Satzes nicht mehr
__/   | http://www.hjp.at/ | zusammenpat. -- Ralph Babel


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

Date: Wed, 17 Dec 2014 23:14:41 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Both substitute and filter
Message-Id: <87fvcdvpge.fsf@doppelsaurus.mobileactivedefense.com>

Georg Bauhaus <bauhaus@futureapps.invalid> writes:

[...]

>> The thing is, code isn't solely written for machines but also for other
>> people.
>
> Precisely. Written by and for people like the people arguing here
> for either way of expressing ideas.

It's not possible to express anything in an intelligible way by uttering
meaningless statements.


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

Date: Wed, 17 Dec 2014 16:01:05 -0800
From: Steve May <stevem_@nogood.com>
Subject: Re: Both substitute and filter
Message-Id: <7Pokw.791877$No4.469189@fx19.iad>

On 12/17/2014 01:59 PM, John Black wrote:
> In article <glkkw.927705$FX2.175120@fx18.iad>, stevem_@nogood.com says...
>>
>> On 12/17/2014 07:32 AM, Rainer Weikusat wrote:
>>> Georg Bauhaus <bauhaus@futureapps.invalid> writes:
>>>> On 16.12.14 16:26, Rainer Weikusat wrote:
>>
>>> my @leaky_bucked = ();
>>>
>>> the assignment is obviously useless to anyone who understands the code
>>> and a gratuitious burden to understanding ("Finally figured it out!
>>> It's useless!") to everybody else. Because of this, it shouldn't exist
>>> to begin with.
>>>
>>
>> An honest question: would you really spend more than an eye blink
>> understanding
>>
>> my @leaky_bucket = ();
>>
>> I truly want to know.  I wouldn't find it remarkable in any way since I
>> use it all the time, but....
>
> Exactly.  I can't believe people are still arguing about this.  The code is pefectly clear
> either way so if the coder prefers it, then its fine.  And there is no computer for which the
> execution time difference would be significant or even measurable.


I don't know. Assuming I've not totally messed up (very possible) with 
the little script below, it looks like there is a performance hit. Not 
enough to worry about unless in a tight loop with many iterations, but...

Oh, and before someone gets after me about the 'return' at the end of 
the test subs, that's there to keep Perl Critic happy. :-)

#! /usr/bin/perl

use strict;
use warnings;

use Benchmark qw(:all) ;


my $ct = 10000000;

timethese( $ct, { a => \&a, b => \&b } ) ;

sub a {
   my @ary;
   $ary[1] = 'fred';
   return;
}

sub b {
   my @ary = ();
   $ary[1] = 'fred';
   return;
}


timethese( $ct, { c => \&c, d => \&d } ) ;

sub c {
   my @ary;
   push @ary, 'fred';
   return;
}

sub d {
   my @ary = ();
   push @ary, 'fred';
   return;
}



=begin

Benchmark: timing 10000000 iterations of a, b...
  	a:  2 wallclock secs ( 1.75 usr +  0.00 sys =  1.75 CPU) @ 
5714285.71/s (n=10000000)
          b:  2 wallclock secs ( 2.68 usr +  0.00 sys =  2.68 CPU) @ 
3731343.28/s (n=10000000)

Benchmark: timing 10000000 iterations of c, d...
          c:  2 wallclock secs ( 1.74 usr +  0.00 sys =  1.74 CPU) @ 
5747126.44/s (n=10000000)
          d:  3 wallclock secs ( 2.63 usr +  0.00 sys =  2.63 CPU) @ 
3802281.37/s (n=10000000)

=cut


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

Date: Wed, 17 Dec 2014 16:44:15 -0800
From: Steve May <stevem_@nogood.com>
Subject: Re: Both substitute and filter
Message-Id: <Brpkw.1040250$Y4.851105@fx24.iad>

On 12/17/2014 01:19 PM, Rainer Weikusat wrote:
> Steve May <stevem_@nogood.com> writes:
>> On 12/17/2014 07:32 AM, Rainer Weikusat wrote:
>>> Georg Bauhaus <bauhaus@futureapps.invalid> writes:
>>>> On 16.12.14 16:26, Rainer Weikusat wrote:
>>
>>> my @leaky_bucked = ();
>>>
>>> the assignment is obviously useless to anyone who understands the code
>>> and a gratuitious burden to understanding ("Finally figured it out!
>>> It's useless!") to everybody else. Because of this, it shouldn't exist
>>> to begin with.
>>>
>>
>> An honest question: would you really spend more than an eye blink
>> understanding
>>
>> my @leaky_bucket = ();
>
> One blink for understanding, two for a silent prayer and another two for
> deleting the = (). Times the number of variables 'superinitialized' in
> this way plus all the blinks of an eye needed to discard all the other
> code without technical purpose. A grain of sand is insignificantly
> small, yet, enough of them clustered together in one place can result in
> a huge dune seriously impeding anyone who has to cross it.
>

Interesting.

Perhaps one reason the assignment doesn't bother me as much is the 
amount of work I do in javascript. I look at a very similar form every 
day (var myList = [];) and since I've been fiddling with javascript 
since the old Netscape LiveScript days.....

Point being, seeing essentially the same pattern in Perl doesn't make 
much impression on me one way or another. Desensitized I guess.


> And there are two other aspects:
>
> 1. Assuming a somewhat large project multiple people work on in a
>     free-style way, each of these people will have his very own set of
>     functionless code annotations he always uses because of historical
>     reasons only known to him. Since everybody also reuses code written
>     by everybody else without ever changing more than what is absolutely
>     necessary, this quickly needs to a situation where half of the code
>     or more (I'm not making this up) is a wild mix of different kinds of
>     things which don't do anything useful and whose theoretical purpose
>     nobody understands.
>

Absolutely true, but in my experience serious large collaborative 
projects typically have (and enforce) style guides for all contributors. 
  Been there, done that, modified my style to meet spec, everybody was 
happy.


> 2. People also learn coding by "copy'n'paste and modify carefully".
>

Yes. I learned to declare variables that way by copying examples from 
Perl programming manuals/docs way back when Perl 5 first came out.

So, it's all Tom C.'s fault. :-)

Thanks for your response Rainer. I can't bring myself to get worked up 
about the issue for a number of reasons, but I understand your point.


Steve



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

Date: Wed, 17 Dec 2014 21:46:18 -0600
From: John Black <jblack@nospam.com>
Subject: Re: Both substitute and filter
Message-Id: <MPG.2efc0a09fb936c6898980e@news.eternal-september.org>

In article <7Pokw.791877$No4.469189@fx19.iad>, stevem_@nogood.com says...
> it looks like there is a performance hit. 

Ok, I stand corrected.  If these kinds of statements make up 30 to 50% of the total 
statements in your program, you might be able to measure a difference...  :-)

John Black


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

Date: Wed, 17 Dec 2014 21:09:07 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Both substitute and filter
Message-Id: <ff2536ca-3f4c-42f1-a256-4dd2b1e4969d@googlegroups.com>

On Wednesday, December 17, 2014 4:01:12 PM UTC-8, Steve May wrote:
> On 12/17/2014 01:59 PM, John Black wrote:
> > In article <glkkw.927705$FX2.175120@fx18.iad>, stevem_@nogood.com says...
> >>
> >> On 12/17/2014 07:32 AM, Rainer Weikusat wrote:
> >>> Georg Bauhaus <bauhaus@futureapps.invalid> writes:
> >>>> On 16.12.14 16:26, Rainer Weikusat wrote:
> >>
> >>> my @leaky_bucked = ();
> >>>
> >>> the assignment is obviously useless to anyone who understands the code
> >>> and a gratuitious burden to understanding ("Finally figured it out!
> >>> It's useless!") to everybody else. Because of this, it shouldn't exist
> >>> to begin with.
> >>>
> >>
> >> An honest question: would you really spend more than an eye blink
> >> understanding
> >>
> >> my @leaky_bucket = ();
> >>
> >> I truly want to know.  I wouldn't find it remarkable in any way since I
> >> use it all the time, but....
> >
> > Exactly.  I can't believe people are still arguing about this.  The code is pefectly clear
> > either way so if the coder prefers it, then its fine.  And there is no computer for which the
> > execution time difference would be significant or even measurable.
> 
> 
> I don't know. Assuming I've not totally messed up (very possible) with 
> the little script below, it looks like there is a performance hit. Not 
> enough to worry about unless in a tight loop with many iterations, but...
> 
> ...  benchmark skipped 

Mea culpa but I'm beating the dead horse only to mention an interesting
fact about the whip. You will definitely see a performance hit because
perl has to do more work:

$ perl -MO=Concise -e 'my @array'
4  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 1 -e:1) v:{ ->3
3     <0> padav[@array:1,2] vM/LVINTRO ->4
-e syntax OK

Intel@Intel-PC /home/ced/perl
$ perl -MO=Concise -e 'my @array = ()'
7  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 1 -e:1) v:{ ->3
6     <2> aassign[t2] vKS ->7
-        <1> ex-list lK ->4
3           <0> pushmark s ->4
-           <0> stub lP ->-
-        <1> ex-list lK ->6
4           <0> pushmark s ->5
5           <0> padav[@array:1,2] lRM*/LVINTRO ->6
-e syntax OK

-- 
Charles DeRykus





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

Date: Wed, 17 Dec 2014 23:39:32 -0800
From: Steve May <stevem_@nogood.com>
Subject: Re: Both substitute and filter
Message-Id: <Wwvkw.804269$DX.527135@fx06.iad>

On 12/17/2014 09:09 PM, C.DeRykus wrote:
> On Wednesday, December 17, 2014 4:01:12 PM UTC-8, Steve May wrote:
>> On 12/17/2014 01:59 PM, John Black wrote:
>>> In article <glkkw.927705$FX2.175120@fx18.iad>, stevem_@nogood.com says...
>>>>
>>>> On 12/17/2014 07:32 AM, Rainer Weikusat wrote:
>>>>> Georg Bauhaus <bauhaus@futureapps.invalid> writes:
>>>>>> On 16.12.14 16:26, Rainer Weikusat wrote:
>>>>
>>>>> my @leaky_bucked = ();
>>>>>
>>>>> the assignment is obviously useless to anyone who understands the code
>>>>> and a gratuitious burden to understanding ("Finally figured it out!
>>>>> It's useless!") to everybody else. Because of this, it shouldn't exist
>>>>> to begin with.
>>>>>
>>>>
>>>> An honest question: would you really spend more than an eye blink
>>>> understanding
>>>>
>>>> my @leaky_bucket = ();
>>>>
>>>> I truly want to know.  I wouldn't find it remarkable in any way since I
>>>> use it all the time, but....
>>>
>>> Exactly.  I can't believe people are still arguing about this.  The code is pefectly clear
>>> either way so if the coder prefers it, then its fine.  And there is no computer for which the
>>> execution time difference would be significant or even measurable.
>>
>>
>> I don't know. Assuming I've not totally messed up (very possible) with
>> the little script below, it looks like there is a performance hit. Not
>> enough to worry about unless in a tight loop with many iterations, but...
>>
>> ...  benchmark skipped
>
> Mea culpa but I'm beating the dead horse only to mention an interesting
> fact about the whip. You will definitely see a performance hit because
> perl has to do more work:
>
> $ perl -MO=Concise -e 'my @array'
> 4  <@> leave[1 ref] vKP/REFC ->(end)
> 1     <0> enter ->2
> 2     <;> nextstate(main 1 -e:1) v:{ ->3
> 3     <0> padav[@array:1,2] vM/LVINTRO ->4
> -e syntax OK
>
> Intel@Intel-PC /home/ced/perl
> $ perl -MO=Concise -e 'my @array = ()'
> 7  <@> leave[1 ref] vKP/REFC ->(end)
> 1     <0> enter ->2
> 2     <;> nextstate(main 1 -e:1) v:{ ->3
> 6     <2> aassign[t2] vKS ->7
> -        <1> ex-list lK ->4
> 3           <0> pushmark s ->4
> -           <0> stub lP ->-
> -        <1> ex-list lK ->6
> 4           <0> pushmark s ->5
> 5           <0> padav[@array:1,2] lRM*/LVINTRO ->6
> -e syntax OK
>


I expected a loss but was surprised at the amount.

Learn something every day. :-)

\s


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

Date: Wed, 17 Dec 2014 23:45:41 -0800
From: Steve May <stevem_@nogood.com>
Subject: Re: Both substitute and filter
Message-Id: <HCvkw.410162$5U6.385310@fx01.iad>

On 12/17/2014 07:46 PM, John Black wrote:
> In article <7Pokw.791877$No4.469189@fx19.iad>, stevem_@nogood.com says...
>> it looks like there is a performance hit.
>
> Ok, I stand corrected.  If these kinds of statements make up 30 to 50% of the total
> statements in your program, you might be able to measure a difference...  :-)
>
> John Black
>

Of course, the program would be doing damn little except declare 
variables so maybe nobody would notice. :-)


\s


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

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 4331
***************************************


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