[#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:82247] [Ruby trunk Bug#13781] Should the safe navigation operator invoke `nil?`
From:
shevegen@...
Date:
2017-08-04 17:21:21 UTC
List:
ruby-core #82247
Issue #13781 has been updated by shevegen (Robert A. Heiler).
> is there an actual use case? I very much doubt there is one
This is what some filed issues appear to be - a mostly theoretical
view that does not appear to be likely to emerge.
When Hiroshi filed the request, I do not think that he had any
"proxy" object in mind - it was simply to avoid compound methods
check e. g:
> if u && u.profile && u.profile.thumbnails && u.profiles.thumbnails.large
versus Activerecord
> if u.try!(:profile).try!(:thumbnails).try!(:large)
To be honest, I actually find the .try! variant more readable than the
&. variant but this is not the topic of course (not sure why activerecord
uses the '!' there, it also makes the chain ugly, in my opinion; perhaps
I am way too picky).
https://bugs.ruby-lang.org/issues/11537
----------------------------------------
Bug #13781: Should the safe navigation operator invoke `nil?`
https://bugs.ruby-lang.org/issues/13781#change-66027
* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.4.1
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
In the following example:
~~~
class Later < BasicObject
def initialize(&block)
raise ::ArgumentError, "Block required" unless block
if block.arity > 0
raise ::ArgumentError, "Cannot store a promise that requires an argument"
end
@block = block
end
def __resolve__
@result ||= @block.call
end
def nil?
__resolve__.nil?
end
def respond_to?(name)
__resolve__.respond_to?(name)
end
def method_missing(name, *args, &block)
__resolve__.__send__(name, *args, &block)
end
end
Person = Struct.new(:name, :age)
person = Later.new do
nil # Person.new("Froob", 200)
end
puts person.nil?
puts person&.name
~~~
The code fails because person is a proxy object.
If safe navigation operator invoked `nil?` it should work. But, it's not clear exactly how the implementation should behave, or whether it's possible to implement this style of proxy.
--
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>