Forum: Ruby-core [ruby-trunk - Feature #7511][Open] short-circuiting logical implication operator

Posted by rits (First Last) (Guest)
on 2012-12-04 22:41
(Received via mailing list)
Issue #7511 has been reported by rits (First Last).

----------------------------------------
Feature #7511: short-circuiting logical implication operator
https://bugs.ruby-lang.org/issues/7511

Author: rits (First Last)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


I find I need logical implication (will use => here) in boolean 
expressions fairly often

and even though a => b is equivalent to !a || b, this substitute is more 
difficult to read and make sense of in long expressions
Posted by naruse (Yui NARUSE) (Guest)
on 2012-12-05 02:33
(Received via mailing list)
Issue #7511 has been updated by naruse (Yui NARUSE).


How about a ? b : true
----------------------------------------
Feature #7511: short-circuiting logical implication operator
https://bugs.ruby-lang.org/issues/7511#change-34400

Author: rits (First Last)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


I find I need logical implication (will use => here) in boolean 
expressions fairly often

and even though a => b is equivalent to !a || b, this substitute is more 
difficult to read and make sense of in long expressions
Posted by rits (First Last) (Guest)
on 2012-12-05 09:11
(Received via mailing list)
Issue #7511 has been updated by rits (First Last).


naruse (Yui NARUSE) wrote:
> How about a ? b : true

One can get along without the implication operator, but for better 
readability / quicker mental parsing, it would be better than the 
existing alternatives, including ternary.

----------------------------------------
Feature #7511: short-circuiting logical implication operator
https://bugs.ruby-lang.org/issues/7511#change-34404

Author: rits (First Last)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


I find I need logical implication (will use => here) in boolean 
expressions fairly often

and even though a => b is equivalent to !a || b, this substitute is more 
difficult to read and make sense of in long expressions
Posted by alexeymuranov (Alexey Muranov) (Guest)
on 2012-12-05 13:47
(Received via mailing list)
Issue #7511 has been updated by alexeymuranov (Alexey Muranov).


I have no opinion about whether it is needed, but a usual mathematical 
syntax would be  `x -> y`. So it can be `-->` for boolean and `->` for 
bitwise. But this could be confusing because of other existing or 
possible uses of `->`, `<-` etc.
----------------------------------------
Feature #7511: short-circuiting logical implication operator
https://bugs.ruby-lang.org/issues/7511#change-34412

Author: rits (First Last)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


I find I need logical implication (will use => here) in boolean 
expressions fairly often

and even though a => b is equivalent to !a || b, this substitute is more 
difficult to read and make sense of in long expressions
Posted by charliesome (Charlie Somerville) (Guest)
on 2012-12-05 13:51
(Received via mailing list)
Issue #7511 has been updated by charliesome (Charlie Somerville).


Ambiguity:

    a -> b {}
----------------------------------------
Feature #7511: short-circuiting logical implication operator
https://bugs.ruby-lang.org/issues/7511#change-34413

Author: rits (First Last)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


I find I need logical implication (will use => here) in boolean 
expressions fairly often

and even though a => b is equivalent to !a || b, this substitute is more 
difficult to read and make sense of in long expressions
Posted by rits (First Last) (Guest)
on 2012-12-05 16:27
(Received via mailing list)
Issue #7511 has been updated by rits (First Last).


charliesome (Charlie Somerville) wrote:
> It isn't something I can imagine would see much use.

implication is very common, the presence or validity of something 
requiring some condition to hold.

if a && b && c && (d => e) && (f => g)
...
end

is a lot more clear than

if a && b && c && (d ? e : true) && (!f || g)
...
end

especially if some of a, b, c, d, e, f, g are non trivial expressions
----------------------------------------
Feature #7511: short-circuiting logical implication operator
https://bugs.ruby-lang.org/issues/7511#change-34420

Author: rits (First Last)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


I find I need logical implication (will use => here) in boolean 
expressions fairly often

and even though a => b is equivalent to !a || b, this substitute is more 
difficult to read and make sense of in long expressions
Posted by mame (Yusuke Endoh) (Guest)
on 2012-12-05 17:03
(Received via mailing list)
Issue #7511 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to matz (Yukihiro Matsumoto)
Target version set to Next Major

Please show a more concrete example.

--
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Feature #7511: short-circuiting logical implication operator
https://bugs.ruby-lang.org/issues/7511#change-34424

Author: rits (First Last)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version: Next Major


I find I need logical implication (will use => here) in boolean 
expressions fairly often

and even though a => b is equivalent to !a || b, this substitute is more 
difficult to read and make sense of in long expressions
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.