Weirdness

2002-11-03 Thread Shevek
Given Perl v5.8.0, stable version at Sep 19 2002 00:33:39, the following
are all valid Perl expressions:

3 * 9
3 ** 9
3 * * 9
3 * * * * 9
3 ** * 9
3 ** * * 9
3 ** * * * 9
3 ** * * * * 9
3 * * *

The following is not:

3 * * * 9

Of course this is a very ed up thing to try, don't ask me why I did. 
But can anyone explain?

S.

-- 
Shevek
I am the Borg.

sub AUTOLOAD{my$i=$AUTOLOAD;my$x=shift;$i=~s/^.*://;print$x\n;eval
qq{*$AUTOLOAD=sub{my\$x=shift;return unless \$x%$i;{$x}(\$x);};};}

foreach my $i (3..65535) { {'2'}($i); }





Re: Weirdness

2002-11-03 Thread Nicholas Clark
On Sun, Nov 03, 2002 at 11:14:44AM +, Shevek wrote:
 Given Perl v5.8.0, stable version at Sep 19 2002 00:33:39, the following
 are all valid Perl expressions:
 
 3 * 9
 3 ** 9
 3 * * 9
 3 * * * * 9
 3 ** * 9
 3 ** * * 9
 3 ** * * * 9
 3 ** * * * * 9
 3 * * *
 
 The following is not:
 
 3 * * * 9
 
 Of course this is a very ed up thing to try, don't ask me why I did. 
 But can anyone explain?

Given this:

perl -le 'print * * '
*main::*

and my limited knowledge of how tokenisers work

when expecting a term, ** or * * will be interpreted as a typeglob of * in main
when expecting an expression, ** will be interpreted as exponentiation
when expecting an expression, * will be interpreted as multiply

and it seems that:

perl -le 'print * 9 '
*main::9

*main::* and *main::9 aren't numeric, so they are treated as 0.

so you had

3 times 9
3 to the power of 9
3 times *main::9
3 times *main::* times 9
3 to the power of *main::9

then '3 ** * * 9' isn't valid, so you must have typed that somewhere.

3 to the power of *main::* times 9
3 to the power of *main::* times *main::9

3 times *main::*

none of the above was checked with Deparse. Here's the last one, as seen by
Deparse:

perl5.8.0 -MO=Deparse -le 'print 3 ** * * * * 9'
BEGIN { $/ = \n; $\ = \n; }
print 3 ** ** * *9;
-e syntax OK

And the reason I know all this - blame Abigail.
(a sig with **  something which has the value 1. ie 0 ** 0, which perl is
treating as 1. I don't know enough serious maths to know if 0 ** 0 is well
defined. See perl6-language for more maths)

Nicholas Clark
-- 
Brainfuck better than perl? http://www.perl.org/advocacy/spoofathon/




Re: Weirdness

2002-11-03 Thread Paul Johnson
On Sun, Nov 03, 2002 at 11:34:53AM +, Nicholas Clark wrote:

[ question and explanation elided ]

 And the reason I know all this - blame Abigail.
 (a sig with **  something which has the value 1. ie 0 ** 0, which perl is
 treating as 1. I don't know enough serious maths to know if 0 ** 0 is well
 defined. See perl6-language for more maths)

0 ** x and x ** 0 have different limits as x approaches 0, so if I
recall correctly , 0 ** 0 is an indeterminate form, but it is generally
accepted (I think) that 1 is the most useful answer because that makes
little things like the binomial theorem work properly.

Disclaimer - it's many years since I did any real maths.

[ Now waiting for someone to say it shows, and give a real answer. ]

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net




Re: webmail

2002-11-03 Thread Paul Makepeace
On Wed, Oct 30, 2002 at 07:49:03PM -0800, Randal L. Schwartz wrote:
  Paul == Paul Makepeace [EMAIL PROTECTED] writes:
 
 Paul I am also amused and puzzled at the people writing huge tracts on why
 Paul PHP is crap while not at the same time acknowledging there are vastly
 Paul more websites written in PHP doing useful things for lots of people than
 Paul there are in perl -- witness the scrabbling to find even remotely
 Paul interesting success story cases for Perl (what recent ones have there
 Paul been?).
 
 A lot of the ones at
 http://perl.apache.org/outstanding/success_stories/ seem recent.
 And I suppose you haven't heard of match.com or citysearch.com or
 ticketmaster.com before?  Oh wait, you're a brit. :)

That's good to see -- match.com is certainly a massive site. Still, it
seems a tiny number to me considering what's out there.

 Paul  I suspect more revenue is generated from PHP sites than Perl
 Paul sites.
 
 I don't.  I suspect PHP runs more hobby sites.  I suspect Perl does
 more of the e-commerce heavy lifting and pretty-lifting.

I dunno, in light of reports like the one on LWN I'm struggling to see
this.

PHP Overtakes Microsoft's ASP as Web's #1 Server-side Scripting
Language: http://lwn.net/Articles/1433/

According to a Netcraft survey published in April 2002, PHP is now
being used by over 24% of the sites on the Internet. Of the 37.6 million
web sites reported worldwide
(http://www.netcraft.com/Survey/index-200204.html), PHP is running on
over 9 million sites and continues to grow at an explosive rate. Over
the past two years PHP has averaged a 6.5% monthly growth rate.

That's an enormous number of hobby sites :-)

Oh well, who knows - my basic point is that for all the interesting
discussion about how bad PHP is there's an awful lot of productive work
going on with it, that same work that probably wouldn't've happened with
perl. (I know at least half a dozen PHPers who were too scared by perl.)

Paul

-- 
Paul Makepeace ... http://paulm.com/

If I could write Java Code, then some masks would be smarter than
 others.
   -- http://paulm.com/toys/surrealism/




Re: webmail

2002-11-03 Thread Dave Wilson
On Mon, Nov 04, 2002 at 12:44:00AM +, Paul Makepeace wrote:

 According to a Netcraft survey published in April 2002, PHP is now
 being used by over 24% of the sites on the Internet. Of the 37.6 million
 web sites reported worldwide
 (http://www.netcraft.com/Survey/index-200204.html), PHP is running on
 over 9 million sites and continues to grow at an explosive rate. Over
 the past two years PHP has averaged a 6.5% monthly growth rate.

 That's an enormous number of hobby sites :-)

 Oh well, who knows - my basic point is that for all the interesting
 discussion about how bad PHP is there's an awful lot of productive work
 going on with it, that same work that probably wouldn't've happened with
 perl. (I know at least half a dozen PHPers who were too scared by perl.)

I think the bad publicity that PHP gets is largely due to two/three things:

a) The speed at which it evolves:

   PHP has went through a crazy development cycle in the last year or
   two.. quite a bit of the API changed to be more uniform, and other
   such language enhancements. This period is not over, Zend2 is on the
   way which will change some of the language syntax, although on saying
   that, perl6 is on the way too, and perl's syntax will probably change
   more than PHP's will with this upgrade.

b) The number of bad PHP programmers:

   PHP is probably one of the easiest web languages in the world to pick
   up. Given that, and the number of .* in 24 hours books available
   for it, the universe now has a surplus of PHP coders who don't really
   know what they are doing.

   As a result of this, we now have a steady stream of security
   vulnerabilities published on major security mailling lists daily
   about insecure PHP packages (I think this is how the discussion
   started?).

   The actual PHP codebase itself has only had a few insecurities -- I
   haven't looked at the figures, but at a guess I'd say less than the
   likes of suidperl (which has been around for quite a long time I must
   admit, but I'm trying to make PHP look good here).

   A properly coded PHP project should be just as secure as it's perl or
   C (or insert-language-here) counterparts. It is the
   In-24-hrs-Newbie who is writing code like
   'system(getenv(USERNAME));'. This could just as easily be done in
   any other language. (please skip the perl tainting rants :).


c) Lack of traditions regarding project management and syntax style:

   Well organized PHP projects are few and far between; I've heard
   hundreds of anti-PHP arguments, most of them valid, but a large
   number have been that PHP does not cope well when given a large
   codebase (1000+ lines).

   If your PHP codebase has got messy, that is your fault, not the
   languages.  PHP doesn't have a recognized way of organizing code
   (like Perl or Python modules), it leaves it up to you to be creative
   in finding a way.

   As a side note, there is a CPAN clone well under way, however, PEAR.


The only real complaint I have with PHP is the memory management, which
I have seen get messy in really simple situations. Apart from that, it's
a nice neat little language. If you keep up with the development of the
language (like any good programmer should anyway), you're sorted.
Admittedly, PHP language development moves about 100 times faster then
any other language at times, but thats just it's nature.

/rant

Dave.




Re: webmail

2002-11-03 Thread Simon Batistoni
On 04/11/02 00:44 +, Paul Makepeace wrote:
 I dunno, in light of reports like the one on LWN I'm struggling to see
 this.
 
 PHP Overtakes Microsoft's ASP as Web's #1 Server-side Scripting
 Language: http://lwn.net/Articles/1433/
 
 According to a Netcraft survey published in April 2002, PHP is now
 being used by over 24% of the sites on the Internet. Of the 37.6 million
 web sites reported worldwide
 (http://www.netcraft.com/Survey/index-200204.html), PHP is running on
 over 9 million sites and continues to grow at an explosive rate. Over
 the past two years PHP has averaged a 6.5% monthly growth rate.
 
 That's an enormous number of hobby sites :-)

Current or ex-Netcrafters can correct me if I'm wrong, but the
netcraft survey basically asks the http server what it's actually
running, and so these figures are, pretty much, simply taken from
distinct domains with an apache reporting that it has mod_php loaded.

There are 2 major points with this:

1) Whilst mod_perl shows up in the same way, there's no direct way of
Netcraft collecting data on vanilla apache servers which are being
used with perl scripts (CGI.pm-enabled or otherwise).

2) Many servers, especially those at bulk hosting companies running
virtual hosts for people, will be compiled with mod_php by
default. Whether it's actually used by any/all of the sites on the box
is a different point.

The statistics may not be that accurate, basically. Having said that,
I don't doubt that PHP is popular, and that it's very useful for a lot
of people in a lot of situations. Personally I haven't used it very
much (my old not-quite-dormant company has a couple of sites running
geeklog, but that's pretty much someone else's responsibility), and I
like the flexibility and power that I have with perl, especially
combined with DBI and TT.

Each to their own, horses for courses, and a bunch of other cliches...