Author: larry
Date: Thu Feb 1 13:33:59 2007
New Revision: 13560
Modified:
doc/trunk/design/syn/S03.pod
doc/trunk/design/syn/S12.pod
Log:
Killed filetest operators! (They were a pain to parse anyway.)
A Pair pattern now queries back to object to ask if it thinks it matches.
Str and IO use .TEST to implement filetests.
Stat buffer caching is now automatic, up to a point.
Modified: doc/trunk/design/syn/S03.pod
==============================================================================
--- doc/trunk/design/syn/S03.pod (original)
+++ doc/trunk/design/syn/S03.pod Thu Feb 1 13:33:59 2007
@@ -14,7 +14,7 @@
Date: 8 Mar 2004
Last Modified: 1 Feb 2007
Number: 3
- Version: 94
+ Version: 95
=head1 Overview
@@ -37,7 +37,7 @@
Additive + - ~ +| +^ ~| ~^ ?| ?^
Junctive and (all) &
Junctive or (any) | ^
- Named unary rand sleep abs -e -r -w -x
+ Named unary rand sleep abs
Nonchaining binary but does <=> leg cmp .. ..^ ^.. ^..^ ff fff
Chaining binary != == < <= > >= eq ne lt le gt ge ~~ === eqv !eqv
Tight and &&
@@ -670,12 +670,6 @@
=item *
-File test operators
-
- -e -r -w -x etc.
-
-=item *
-
The C<item> contextualizer
item
@@ -1414,19 +1408,27 @@
=item *
-The filetest operators now return a result that is both a
-boolean (or in the case of C<-s>, a number) and a stat buffer, so
-there is no longer any need for PerlĀ 5's C<_> term. Instead just
-cascade tests to "and" them:
-
- if -r -w -x $filename {...}
-
-Or put the value in a variable to do anything fancier:
-
- $sb = -e $filename;
- if -r $sb {...}
- if -w $sb {...}
- if -x $sb {...}
+The filetest operators now gone. We now use a Pair as a pattern to
+get the same effect:
+
+ if $filename ~~ :e { say "exists" }
+
+These tests may be combined via junctions:
+
+ given $handle {
+ when all :r :w :x {...}
+ when :w | :x {...}
+ when * {...}
+ }
+
+In general, the user need not worry about caching the stat buffer.
+The stat buffer will automatically be reused if the same object is
+queried and the stat buffer has not "expired", where that is defined
+as older than a second or so. If this is a concern, an explicit stat()
+or lstat() will automatically reset the stat buffer, as will switching
+to a different filename or handle.
+
+Note that C<$file ~~ :s> still returns the filesize.
=item *
@@ -1438,8 +1440,8 @@
The postfix interpretation of an operator may be overridden by
use of a quoted method call, which calls the prefix form instead.
So C<x().!> is always the postfix operator, but C<x().'!'> will always
-call C<!x()>. In particular, you can say things like C<$array.'@'> and
-C<$filename.'-e'.'-r'>. You may even say things like C<$fh.'='>, which
+call C<!x()>. In particular, you can say things like C<$array.'@'>.
+and C<$fh.'='>, which
because of the quotes will not be confused lexically with C<$fh.=new>.
=item *
@@ -2125,6 +2127,8 @@
Any Num numeric equality +$_ == X
Any Str string equality ~$_ eq X
+ Any Pair test object .TEST(X) (Str,IO do filetest)
+
Set Set identical sets $_ === X
Hash Set hash keys same set $_.keys === X
Any Set force set comparison Set($_) === X
Modified: doc/trunk/design/syn/S12.pod
==============================================================================
--- doc/trunk/design/syn/S12.pod (original)
+++ doc/trunk/design/syn/S12.pod Thu Feb 1 13:33:59 2007
@@ -12,9 +12,9 @@
Maintainer: Larry Wall <[EMAIL PROTECTED]>
Date: 27 Oct 2004
- Last Modified: 28 Dec 2006
+ Last Modified: 1 Feb 2007
Number: 12
- Version: 35
+ Version: 36
=head1 Overview
@@ -231,8 +231,8 @@
The latter is especially useful for postfix forms that might be confusing
to the lexer or to the human reader:
- $filename.'-e' # same as -e $filename.
- .'-e' # same as -e $_
+ $filename.'+' # same as +$filename.
+ .'+' # same as +$_
And in fact, if there is a choice between a unary prefix and a postfix
operator, the indirect forms will choose the prefix operator. See S03.