The proper way to open()
Smylers at stripey.com
Wed Feb 1 16:04:45 GMT 2012
David Cantrell writes:
> On 01/02/2012 13:34, Smylers wrote:
> > > On Mon, Jan 30, 2012 at 9:12 AM, David Cantrell
> > > <david at cantrell.org.uk> wrote:
> > >
> > > > No. The correct solution to buggy code caused by precedence is
> > > > not to invent a new level of precedence, but to use parens.
> > In particular, I don't look at a situation where OR behaviour is
> > required and consider what precedence level is needed.
> Nor do I. I use ||, and parens around (most) functions' arguments.
Indeed, and I freely admit that your way works too.
> > To me the above open line doesn't look like a precedence issue, but
> > using an operator in a way which doesn't fit.
> Use of || in situations like this isn't unheard of in other languages.
> C, for example.
Yeah, I encountered Perl before I'd learnt C, or shell scripting. I said
"to me" cos I was describing how it looks to me, but obviously it
doesn't look like that to everybody else, and nor am I claiming it
> > That the two operators happen to be different precedence variants of
> > each other is an implementation detail, and that one can always be
> > achieved with t'other doesn't seem a reason to avoid it any more
> > than it would be to avoid || because that Mr De Morgan showed it can
> > be implemented with a combination of ! and &&.
> Now you're being silly.
Well the suggestion that a programming language could do without OR
because it has both AND and NOT was definitely silly.
But that I consider || and or as two separate operators and when using
them don't think about one being like t'other with a different
precedence is a genuine description of how I program, honest!
> > > > I do realise that it was the p5p gang who invented the new level
> > > > of precedence, but that doesn't mean you should play along.
> > The sentiment of not blindly using a feature just because at some
> > point it got added to core Perl sounds most sensible to me.
> Still silly.
Sorry, I was attempting to agree with you there. Not about the number of
precedence levels, but your underlying point about not just playing
along because something was invented by P5P.
Only I wrote "core Perl" instead of "P5P", because somebody else
suggested it was specifically Larry rather than P5P responsible here.
> I have never suggested that we should never use things added to perl
> since some arbitrary point.
No, me neither, and my apologies if it looked like I was suggesting you
had. I meant "added" in the loosest sense that all features have been
added, because initially there wasn't Perl at all.
> I merely suggest not using things that I think are stupid or
> > And in general I find avoiding unnecessary parens is good, cos it
> > means when I do have parens there are fewer of them, so it's easier
> > to see at a glance how they match
> Your editor can help with this. Hit % in vim or C-M-S-H-iaiacthulhu
> while kicking an aardvark in emacs.
I do, but moving the cursor to a bracket and pressing % involves more
than "at a glance", and I like my code to be glanceable. Others may
More information about the london.pm