[#82311] [Ruby trunk Bug#13794] Infinite loop of sched_yield — charlie@...
Issue #13794 has been reported by catphish (Charlie Smurthwaite).
4 messages
2017/08/09
[#82518] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — mame@...
Issue #13618 has been updated by mame (Yusuke Endoh).
5 messages
2017/08/30
[#82552] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2017/08/31
mame@ruby-lang.org wrote:
[#82756] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wrong <normalperson@...>
2017/09/12
Eric Wrong <normalperson@yhbt.net> wrote:
[ruby-core:82419] [Ruby trunk Feature#13820] Add a nill coalescing operator
From:
nobu@...
Date:
2017-08-18 00:16:35 UTC
List:
ruby-core #82419
Issue #13820 has been updated by nobu (Nobuyoshi Nakada).
williamn (William Newbery) wrote:
> shevegen (Robert A. Heiler) wrote:
> > By the way, did you actually propose an actual syntax? The two '?'?
>
> Not really personally set on any given syntax, just `??` and `//` are familiar to me from other programming. Although actually for `??` specifically, I guess the fact Ruby uses it in both methods and ternary causes a conflict rather than just one or the other (`x.nil?? "was nil" : "not nil"`). I wouldn't know if the parser can figure that out or not.
`??` is a string literal, and `//` is a regexp literal.
> ```ruby
> def fetch(id, **opts)
> host = opts[:host] || default_host
> https = opts[:https] || true
> port = opts[:port] || (https ? 443 : 80)
Why not keyword arguments?
----------------------------------------
Feature #13820: Add a nill coalescing operator
https://bugs.ruby-lang.org/issues/13820#change-66224
* Author: williamn (William Newbery)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
It would be nice if Ruby had an operator that only considered `nil` as false, like the null coalescing operators or "Logical Defined-Or operator" (Perl) found in some other languages. Ive seen things like `//` and `//=`m `??` and `??=`, or `?:` used for this.
This would work like `||` and `||=` for short circuiting etc. except that only `nil` is considered a false condition.
While Ruby considers only "false" and "nil" as false, with everything else true ("", [], {}, etc.) I still find occasionally people trip up when using logical or, `||` and `||=` when the value may be false.
```ruby
a = 0 || 55 # = 0 Ruby already considers 0, "", etc. as true (oter languages do differ a lot here)
a = 0 ?? 55 # = 0 So no change here
a = nil || 55 # = 55, nil is false so right side is evaulated.
a = nil ?? 55 # = 55, again no change
a = false || 55 # = 55, however false is false for logical or
a = false ?? 55 # = false, but its still a non-nil value
```
For example when doing things like:
```ruby
def lazy
@lazy ||= compute_this
end
def fetch(id, **opts)
host = opts[:host] || default_host
https = opts[:https] || true
port = opts[:port] || (https ? 443 : 80)
...
```
Normally the intention is to use a default value or compute an action if no value is provided, which if the value may be false then requires special handling, or sometimes is missed and results in a bug.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>