Anyhow, those familiar with logics might be familiar with "implication" operator: A -> B, from A follows B, or in more primitive terms: !A || (A && B). Used to say things like "if it rains, then it winds" - if it doesn't rain, the statement might as well be true but not applicable, if it does rain then we'll see if the statement is true by checking if it winds too.
My point? That perl should have one. It may sound like trivial operator ... but believe it or not, I actually encountered a case where it would have come in handy. I am writing this personal web proxy in perl that tampers with CGI requests. Now, multipart POST requests didn't go through because, in case of POST, I just fed the body to CGI.pm which interpreted it all wrong. Upon writing a check to only accept content-type: application/x-www-form-urlencoded, I ended up writing as following:
($method ne "post" || ($method eq "post" && $contenttype eq "application/x-www-form-urlencoded")
As you can clearly see, it would have been better written
($method eq "post") -> ($contenttype eq "application/x-www-form-urlencoded)
(of course, => operator is already in use. And so is ->.)
Still, with current operatorness, the way I wrote it is unsatisfactory. It duplicated terms ($method ne "post" vs. $method eq "post"), which is equivalent to code copying, which is Bad Thing. Right? I can think of some more ways to write this, but they all end up copying terms, so I suspect there really isn't way to make it neat with what there is.
So, maybe there should be implication-operator? And now that I think of it, why isn't there high-precence XOR operator (one corresponding to && and ||, "xor" is impractical with too low precedence)? Is it that they simply couldn't figure out proper characters for them?
...
OK, OK, I admit this might be a "bit" trivial issue but this really troubles me. And this is "Meditations" which apparently is cover name for "Ramblings", isn't it?
-Kaatunut
In reply to Implication operator by kaatunut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |