Re: RFC 320 (v1) Allow grouping of -X file tests and add Cfiletest builtin

2000-09-30 Thread Bart Lateur

On Tue, 26 Sep 2000 11:13:30 -0700, Nathan Wiger wrote:

   -{rwx};   # negation of a hashref

That's a weird hashref. Odd number of arguments, anyone?

If rwx is supposed to be a sub, we could say that this is an exception,
just like $hash{bareword} is an exception. So, if you want the sub, use
parens:

-{rwx()}

Need I still say that this one is my favourite?   :-)

-- 
Bart.



Re: RFC 320 (v1) Allow grouping of -X file tests and add Cfiletest builtin

2000-09-27 Thread Philip Newton

On Tue, 26 Sep 2000, Nathan Wiger wrote:

 John Porter wrote:
  
  Yeah, not to mention the fact that many modules, notably CGI.pm,
  are arranged to allow to use unquoted strings of the form -name:
  
  print textfield( -name = 'description' );
 
 Well, this one's not an issue, because = auto-quotes the LHS. It's the
 same as this:
 
   print textfield( "-name", 'description' );

Actually, more like this:

print textfield( -'name', 'description' );

Try putting it through -MO=Deparse. I guess the quoting behaviour of =
"binds" more strongly than the hyphen, so that "-name =" is interpreted
as unary minus + bareword 'name' + big arrow, leading to unary minus +
quoted bareword 'name' + big arrow, which is equivalent to - "name" and a
comma. Fortunately, - "string" doesn't convert "string" to a number (0)
and then apply negation but results in "-string" (`perldoc perlop` says:
"If the operand is an identifier, a string consisting of a minus sign
concatenated with the identifier is returned. [...] One effect of these
rules is that `-bareword' is equivalent to `"-bareword"'."

Cheers,
Philip
-- 
Philip Newton [EMAIL PROTECTED]




Re: RFC 320 (v1) Allow grouping of -X file tests and add Cfiletest builtin

2000-09-26 Thread Jonathan Scott Duff

On Tue, Sep 26, 2000 at 05:53:13AM -, Nate Wiger wrote:
 Currently, file tests cannot be grouped, resulting in very long
 expressions when one wants to check to make sure some thing is a
 readable, writeable, executable directory:
 
if ( -d $file  -r $file  -w $file  -x $file ) { ... }

Non-novice perl programmers would probably write this as you have
below with the special _ filehandle.  Perhaps you should move that to
the fore and comment on it's unreadability and general ickiness :-)

 It would be really nice if these could be grouped instead:
 
if ( -drwx $file ) { ... }

Indeed it would.

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]



Re: RFC 320 (v1) Allow grouping of -X file tests and add Cfiletest builtin

2000-09-26 Thread John L. Allen



On 26 Sep 2000, Perl6 RFC Librarian wrote:

 =head1 TITLE
 
 Allow grouping of -X file tests and add Cfiletest builtin

Nice summary.  Thanks.

 =head1 IMPLEMENTATION
 
 This would involve making C-[a-zA-Z]+ a special token in all contexts,
 serving as a shortcut for the Cfiletest builtin.
 
 =head1 MIGRATION
 
 There is a subtle trap if you are negating subroutines:
 
$result = -drwx $file;
 
 And expect this to be parsed like this:
 
$result = - drwx($file);
 
 However, usage such as this is exceedingly unlikely, and can simply be
 resolved by the p52p6 translator looking for C-([a-zA-Z]{2,}) and
 replacing it with C- $1, since injecting a single space will break up
 the token.

I can't believe that special-casing the token -[rwxoRWXOezsfdlpSbctugkTBMAC]+
is an acceptble solution.  I mean think of all the existing perl keywords 
that that already matches: -pos, -cos, -lc, -uc, -fork, -use, -pop, -exp, 
-oct, -log, -ord + others!.  A lot of these already have a legitimate 
not-filetest meaning, others not :-)  So it still seems to me that some 
sort of disambiguating syntax is needed, if not actually findable, to 
save this filetest grouping idea of mine from the scrap heap.  I guess 
the p5-to-p6 converter could still resolve this as you stated, but I just 
don't like it...

John.



Re: RFC 320 (v1) Allow grouping of -X file tests and add Cfiletest builtin

2000-09-26 Thread John Porter

John L. Allen wrote:
 
 I can't believe that special-casing the token -[rwxoRWXOezsfdlpSbctugkTBMAC]+
 is an acceptble solution.  I mean think of all the existing perl keywords 
 that that already matches: -pos, -cos, -lc, -uc, -fork, -use, -pop, -exp, 
 -oct, -log, -ord + others!.  A lot of these already have a legitimate 
 not-filetest meaning, others not :-)  

Yeah, not to mention the fact that many modules, notably CGI.pm,
are arranged to allow to use unquoted strings of the form -name:

print textfield( -name = 'description' );

-- 
John Porter

Aus des Weltalls ferne  funken Radiosterne.




RFC 320 (v1) Allow grouping of -X file tests and add Cfiletest builtin

2000-09-25 Thread Perl6 RFC Librarian

This and other RFCs are available on the web at
  http://dev.perl.org/rfc/

=head1 TITLE

Allow grouping of -X file tests and add Cfiletest builtin

=head1 VERSION

  Maintainer: Nathan Wiger [EMAIL PROTECTED]
  Date: 25 Sep 2000
  Mailing List: [EMAIL PROTECTED]
  Number: 
  320
  Status: Developing

=head1 ABSTRACT

Currently, file tests cannot be grouped, resulting in very long
expressions when one wants to check to make sure some thing is a
readable, writeable, executable directory:

   if ( -d $file  -r $file  -w $file  -x $file ) { ... }

It would be really nice if these could be grouped instead:

   if ( -drwx $file ) { ... }

Notice how much easier this is to read and write.

=head1 DESCRIPTION

=head2 File Test Grouping

See above. Multiple file tests, when grouped, should be ANDed together.
This RFC does not propose a way to OR them, since usage like this:

   if ( -d $file || -r $file || -w $file || -x $file ) { ... }

Is highly uncommon, to say the least.

Notice this has the nice side effect of eliminating the need for C_ in
many cases, since this:

   if ( -d $file  -r _  -w _  -x _ ) { ... }

Can simply be written as a single grouped file test, as shown above. If
you need to check for more complex logic, you still have to do that
separately:

   if ( -drwx $file and ! -h $file )  { ... }

This is the simplest and also probably the clearest way to implement
this.

=head2 New Cfiletest Builtin

This RFC also proposes a new Cfiletest builtin that is actually what
is used for these tests. The C-[a-zA-Z]+ form is simply a shortcut to
this builtin, just like  is a shortcut to Creadline. So:

   if ( -rwdx $file ) { ... }

Is really just a shortcut to the Cfiletest builtin:

   if ( filetest $file, 'rwdx' ) { ... }

Either form could be used, depending on the user's preferences (just
like Creadline).

=head1 IMPLEMENTATION

This would involve making C-[a-zA-Z]+ a special token in all contexts,
serving as a shortcut for the Cfiletest builtin.

=head1 MIGRATION

There is a subtle trap if you are negating subroutines:

   $result = -drwx $file;

And expect this to be parsed like this:

   $result = - drwx($file);

However, usage such as this is exceedingly unlikely, and can simply be
resolved by the p52p6 translator looking for C-([a-zA-Z]{2,}) and
replacing it with C- $1, since injecting a single space will break up
the token.

=head1 REFERENCES

This grew out of a discussion on RFC 290 between myself, John Allen,
Clayton Scott, Bart Lateur, and others