-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
smartmatch PATCH 1 of 2 for 5.14.1: perlop.pod #11363
Comments
From tchrist@perl.comThis is the first of two inextricably linked doc patches mostly The thrust of this patch is to move the description of the ~~ The 65-column nroff manpage limit is severely troublesome. I --tom |
From @chipdudeOn Tue, May 17, 2011 at 1:14 PM, tchrist1 <perlbug-followup@perl.org> wrote:
Indeed, thank you. This is quite a chunk of text to digest.
Shirley, this is an obsolete requirement. Heck, my TRS-80 Model I |
The RT System itself - Status changed from 'new' to 'open' |
From tchrist@perl.comHere is a patch against the first patch, perlop-smartmatch-patch-on-patch.patch --tom |
From tchrist@perl.comperlop-smartmatch-patch-on-patch.patch--- perlop.pod 2011-05-17 14:01:55.000000000 -0600
+++ new/perlop.pod 2011-05-18 07:36:52.000000000 -0600
@@ -498,7 +498,7 @@
precedence, C<~~> returns 1 for true and C<""> for false. It is often best
read aloud as "in", "inside of", or "is contained in", because the left
operand is often looked for I<inside> the right operand. That makes the
-order of the operands to the smartmatch operand is often opposite that of
+order of the operands to the smartmatch operand often opposite to that of
the regular match operator. In other words, the "smaller" thing is usually
placed in the left operand and the larger one in the right.
@@ -527,7 +527,7 @@
like: grep { /Regexp/ } ARRAY
undef ARRAY undef in ARRAY
like: grep { !defined } ARRAY
- Any ARRAY smart match each ARRAY element[3]
+ Any ARRAY smartmatch each ARRAY element[3]
like: grep { Any ~~ $_ } ARRAY
Right operand is a HASH:
@@ -591,7 +591,7 @@
Empty hashes or arrays match.
=item 2.
-That is, each element smart-matches the element of the same index in the other array.[3]
+That is, each element smartmatches the element of the same index in the other array.[3]
=item 3.
If a circular reference is found, fall back to referential equality.
@@ -607,7 +607,7 @@
involving hashes only consider hash keys, never hash values.
The "like" code entry is not always an exact rendition. For example, the
-smart match operator short-circuits whenever possible, but C<grep> does
+smartmatch operator short-circuits whenever possible, but C<grep> does
not. Also, C<grep> in scalar context returns the number of matches, but
C<~~> returns only true or false.
@@ -640,9 +640,9 @@
say "some keys end in e" if /e$/ ~~ %hash;
say "some keys end in e" if /e$/ ~~ \%hash;
-Two arrays smartmatch if each element in the first array smart
-matches (that is, is "in") the corresponding element in the
-second array, recursively.
+Two arrays smartmatch if each element in the first array smartmatches
+(that is, is "in") the corresponding element in the second array,
+recursively.
use v5.10.1;
my @little = qw(red blue green);
@@ -721,12 +721,12 @@
=head3 Smartmatching of Objects
-To avoid relying on an object's underlying representation, if the smart
-match's right operand is an object that doesn't overload C<~~>, it raises the
-exception "C<Smart matching a non-overloaded object breaks encapsulation>".
-That's because one has no business digging around to see whether something
-is "in" an object. These are all illegal on objects without a C<~~>
-overload:
+To avoid relying on an object's underlying representation, if the
+smartmatch's right operand is an object that doesn't overload C<~~>,
+it raises the exception "C<Smartmatching a non-overloaded object
+breaks encapsulation>". That's because one has no business digging
+around to see whether something is "in" an object. These are all
+illegal on objects without a C<~~> overload:
%hash ~~ $object
42 ~~ $object
|
From tchrist@perl.comChip Salzenberg <rev.chip@gmail.com> wrote
Manpages *can* get linewrapped or snipped at 65 columns. Currently
Well, 100 isn't actually enough. See below. But I very much feel the table would be easier to read this way: 1 2 3 4 5 6 7 8 9 10 11 12 13 Left Right Description and pseudocode Like ARRAY1 ARRAY2 recurse on paired elements of ARRAY1 and ARRAY2[2] ARRAY1[0] ~~ ARRAY2[0] && ARRAY1[1] ~~ ARRAY2[1] && ... HASH1 HASH2 all same keys in both HASHes keys HASH1 == grep { exists HASH2->{$_} } keys HASH1 ARRAY CODE sub returns true on all ARRAY elements[1] !grep { !CODE->($_) } ARRAY ARRAY Regexp any ARRAY elements match Regexp grep { /Regexp/ } ARRAY Object Any invoke ~~ overloading on Object, or fall back to... Than I would this: 1 2 3 4 5 6 7 8 Left Right Description and pseudocode Any Object invoke ~~ overloading on Object, or die Right operand is an ARRAY: Left Right Description and pseudocode Right operand is a HASH: Left Right Description and pseudocode Right operand is CODE: Left Right Description and pseudocode Right operand is a Regexp: Left Right Description and pseudocode Other: Left Right Description and pseudocode Any Num numeric equality Suggestions? --tom |
From rra@stanford.eduTom Christiansen <tchrist@perl.com> writes:
Most of the man implementations I've seen recently have started wrapping
[...]
I actually prefer the second one even with a wide window because my eyes One thing that's worth remembering when it comes to going to longer line -- |
From peter@peknet.comRuss Allbery wrote on 05/18/2011 12:53 PM:
Having been, in years past, the person responsible for maintaining the Russ's rationale below is the big reason.
+1 on behalf of those of us with aging eyes. -- |
From @cpansproutOn Tue May 17 13:14:03 2011, tom christiansen wrote:
With all your doc patches, you seem to be working against yourself. :-) patching file pod/perlop.pod |
From @cpansproutOn Sun May 22 13:46:06 2011, sprout wrote:
I’ve applied the first patch as 1ca345e. Since I had to apply The second one I applied as 40bec8a. Thank you. P.S.: Lots of whitespace changes and reflow make it hard to resolve -- Father Chrysostomos |
From @cpansproutOn Thu Jan 05 20:30:58 2012, sprout wrote:
I forgot to mention: I adjusted the table a bit to fit nicely in an -- Father Chrysostomos |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#90906 (status was 'resolved')
Searchable as RT90906$
The text was updated successfully, but these errors were encountered: