Re: Lvaluability

2001-04-28 Thread Graham Barr

On Sat, Apr 28, 2001 at 03:11:08AM +0100, Simon Cozens wrote:
 substr($foo, 1, 3) = hi!; # We all know this.
 splice(@foo, 1, 3) = @bar;  # But the lack of this seems asymmetric

An originally we had

  splice(@foo, 1, 3, @bar);

but not

  substr($foo, 1, 3, hi!);

which are more useful, IMO, as they return what was replaced. Where
the assignment version returns what was assigned.


 $baz = $foo.bar;# Surely this is just overloaded . being a
 # subroutine in $foo's package called with a
 # bareword --- $foo-concat(bar)

 $foo.bar = $baz;# sub concat :lvalue { ... }

I will leave those :)

 $#array = 10;   # We can currently change an array's length
 length($scalar) = 10;   # But not this?

and we have keys(%hash) = 10 to set the number of buckets in the hash

 -s $filename = 0;   # calls trunc()
 -M $filename = 0;   # calls utime()
 
 #(And now, over to Abigail...)
 $_ = foobar;
 /foo/  = baz; # Now $_ = bazbar
 /ba./g = one two; # Now $_ = onetwo, using Larry's new  qw

I don't remember seeing anything about  as qw, can you give me a reference

 # Oh, why stop there?
 /../g  = sub { ... }# Calls the sub 3 times, replacing each pair of
 # characters with the return value.

I was going to respond to the lines above with do we need another way to do s///
but this one would probably make it an advantage. Or is this the same as s/../foo()/ge 
?

Graham.



Re: Flexible parsing (was Tying Overloading)

2001-04-28 Thread Damian Conway

I think we have to be careful here.  We should ask people to name site
policy files after their site, and not use a generic name like
site_policy, since we'd be likely to end up with 20 different
standard site_policy files wandering around the net.  So something
like

use OReilly::Policy;

or

use Mongolian::Navy::ProcurementOffice::Policy;

might be more in order.

You Americans and your non-ISO penchant for putting the specific before
the general. Surely that should be:

use Policy::O::Reilly;  # really gonna miss that ' package separator ;-)

or

use Policy::Mongolian::Navy::Office::Procurement;

Next you'll be putting the month and day before the year in dates!

Damian



Re: a modest proposal Re: s/./~/g

2001-04-28 Thread Larry Wall

Simon Cozens writes:
: Hey, that would make _ _ __ legal Perl code. Abigail, Abigail!

Now we just need to make ... ___ ... mean something exceptional.

: (I still prefer ~, but acknowledge that this is just bikeshed painting.)

Bikesheds need to be painted occasionally.

Larry



Re: Flexible parsing (was Tying Overloading)

2001-04-28 Thread Larry Wall

[EMAIL PROTECTED] writes:
: use OReilly::Policy;
: 
: or
: 
: use Mongolian::Navy::ProcurementOffice::Policy;
: 
: might be more in order.
: 
: You Americans and your non-ISO penchant for putting the specific before
: the general. Surely that should be:
: 
: use Policy::O::Reilly;# really gonna miss that ' package separator 
:;-)
: 
: or
: 
: use Policy::Mongolian::Navy::Office::Procurement;

Well, I did say more in order.  I didn't say how much more.

: Next you'll be putting the month and day before the year in dates!

No, that isn't next, that was previous.  Perhaps, being hemispherically
challenged, you're looking at it upside down.  (-:, er, that is, :-)

Larry



Re: Flexible parsing (was Tying Overloading)

2001-04-28 Thread Dan Sugalski

At 01:51 PM 4/27/2001 -0700, Larry Wall wrote:
Dan Sugalski writes:
: Besides, having the site administrator forbid the installation of parser
: tweaks might not be what is wanted. If we get PPython in there, a site may
: well have a Python.pm module handy, and source might start:
:
:use site_policy qw(Python);
:
: for modules that were all-Python, or
:
:use site_policy qw(Perl);
:
: for ones that were all-perl. The site-policy file would, amongst other
: things, perhaps lock down the parser so you couldn't switch languages in
: mid-file.

I think we have to be careful here.  We should ask people to name site
policy files after their site, and not use a generic name like
site_policy, since we'd be likely to end up with 20 different
standard site_policy files wandering around the net.

Well, I was thinking that generally the site policy would be expressed in a 
single file, and might look something like:

   Perl:
 set parser Perl (global);
 set warnings on (global, fixed);
 set strict on (global, fixed);
   Python:
 set parser Python (global);
   EasyPerl:
 set parser Perl (global);
 set warnings on (global);
 set strict off;

Basically a simple config file that can be protected as the site 
administrator might see fit, with a simple syntax rather than perl code. 
(Though if the perl code's straightforward for this stuff, then it doesn't 
much matter either way)

I hadn't really considered having a separate module for each type of site 
policy decision.

Dan

--it's like this---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk




Re: a modest proposal Re: s/./~/g

2001-04-28 Thread Damian Conway

: Hey, that would make _ _ __ legal Perl code. Abigail, Abigail!

Now we just need to make ... ___ ... mean something exceptional.

Just download the Bleach.pm module from the CPAN.
It includes Morse.pm.

Damian
---cut---cut---cut---cut---cut--

use Morse;
.--.-..--..---.-.--..--.-..--..---.-.--.
.-.----..-..---.-..-.--..---.--.
..-.---..-...-...-..--..-.-.-.--.-..
..-.-.--.-..--..-.-...---.-..---.--.
.-...-..--.---...-.-



Re: Flexible parsing (was Tying Overloading)

2001-04-28 Thread Larry Wall

Dan Sugalski writes:
: I hadn't really considered having a separate module for each type of site 
: policy decision.

Er, neither had I.  Each site only has one policy file.  I just want it
named after the actual site, not some generic name like Policy.  I
think policy files are inherently non-portable, so they should be named
that way.

Larry