logo       

Re: declarative syntax: msg#00093

Subject: Re: declarative syntax
--- Eric Wilhelm <scratchcomputing@xxxxxxxxx> wrote:

> # from Sergei Steshenko
> # on Sunday 18 March 2007 02:15 pm:
> 
> >funky_array => [1, 2, 3, 5, 8 ...],
> ># element is the some of previous two,
> ># and this way 100 times; 
> 
> >So, this is Perl, and there is more than one to do it, and I would do
> > it this way:
> >
> >{
> >...
> >funky_array => do{
> >                 my @tmp_array;  # no name clash danger, the scope
> >                                 #  protects from name contention
> >
> >                 my $number_of_times = 100; # I said 100 times, dodn't
> > I ?
> >
> >                 my $previous_element = 0;
> >                 my $element = 1;
> >
> >                 while($number_of_times-- > 0)
> >                   {
> >                   $element += $previous_element;
> >                   push @tmp_array, $element;
> >                   $previous_element = $element;
> >                   }
> >
> >                 \@tmp_array; # the array reference to be returned
> >                 }
> >};
> >
> >So, the point of this example is that there should be
> > canonical/normalized data structure and there can be infinite number
> > of ways to produce it.
> 
> Fine.  But, you should be able to skim over the code in much less space.  
> When you want to build something based on a rolling pair of values, why 
> not use a rolling pair of values?
> 
>   ...
>   funky_array => do {my @p = (1,2);
>     [1,2,map({push(@p, my $v = shift(@p)+$p[0]); $v} 3..100)]},
>   ...

Why should I load my brain trying to understand what $p means ?

And why should help those claiming Perl is unreadable ?

And what is $v if I may ?

I prefer readable code, not a short one.

I remember a few days ago a colleague of mine was saying "'i' is current and 
'j' is
previous". And the colleague had a real difficulty debugging her own code.
And I wanted to ask her "Why did you give your variables meaningless names in 
the
first place ?".

I wouldn't have written such a code in the first place - in my code previous is
previous and current is current.

Sorry.

--Sergei.

Applications From Scratch: http://appsfromscratch.berlios.de/



 
____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
web.pylons.gene...    hurd.l4/2002-10...    kernel.commits....    user-groups.lin...    yellowdog.gener...    java.drools.use...    security.openva...    package-managem...    linux.debian.us...    qnx.openqnx.dev...    genealogy.gramp...    file-systems.if...    voip.wengophone...    tex.context/200...    ietf.smime/2003...    audio.csound.de...    culture.region....    xfree86.devel/2...    mobile.kannel.u...    distributed.con...    education.engli...    org.user-groups...    bug-tracking.gn...    recreation.bicy...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe