Front page | perl.perl5.porters |
Postings from February 2020
Re: chained comparisons
February 6, 2020 03:05
Re: chained comparisons
Message ID: CANgJU+WDcHuZD2CvjxTQU9BDp1SqZptH_OY6_tRxpQJOQQSDYQ@mail.gmail.com
On Wed, 5 Feb 2020 at 18:14, demerphq <firstname.lastname@example.org> wrote:
> On Wed, 5 Feb 2020 at 13:13, Smylers <email@example.com> wrote:
>> Zefram writes:
>> > Branch zefram/cmpchain at <git://river.fysh.org/zefram/perl.git> may be
>> > of some interest.
>> Nice — that's definitely of interest! Thank you.
> Agreed a million times over.
>> A few small doc suggestions. Re:
>> A sequence of relational operators, such as
>> S<C<"$a E<lt> $b E<lt>= $c">>, does not group in accordance with left
>> or right associativity, which would produce the almost-useless result
>> of using the truth-value result of one comparison as a comparand in
>> another comparison. Instead the comparisons are I<chained>: each
>> comparison is performed on the two arguments surrounding it, with each
>> interior argument taking part in two comparisons, and the comparison
>> results are implicitly ANDed.
>> • I think for somebody first encountering this feature, it's more useful
>> to state what it does, before what it doesn't.
>> Specifically “You can chain operators like $a < $b <$c” is
>> conceptually quite easy to understand, even for beginners.
>> Thinking about what that would do were it not for chaining, involving
>> associativity and the truth value of one comparison being used in
>> another, isn't necessary in order to be able to use chaining, as well
>> as being harder to think about.
> I think this is pretty reasonable feedback. If Zefram doesn't push a
> doc-fix I will. I do think there is some use to explain the difference, but
> after explaining the point. Someone used to the standard formulation might
> think it is syntactic sugar for the expanded expression, but it is more
> clever than that.
>> • The word ‘comparand’ doesn't currently appear anywhere else in Perl's
>> docs. It's a bit jargony, and may be offputting to people unfamiliar
>> with the word. I haven't looked to see how comparand's are referred to
>> elsewhere in the docs, but if there's a reasonably concise alternative
>> which can be used, that may be better.
> I'm inclined to think that "dumbing it down" will actually be
> counter-productive and make the docs less clear not more. As the saying
> goes "everything should be as simple as possible but not simpler".
I need to eat my words here. I redid the pod and dumbing it down did not
end up being counter productive IMO.
See bb8b81ab9014b5373724267eedb7425bed3ad2ee in zefram/cmpchain in main.git
on github (I pushed it over from zeframs repo).
I believe my pod changes cover all of your feedback, please let me know
what you think.
perl -Mre=debug -e "/just|another|perl|hacker/"