[#89555] [Ruby trunk Feature#15251] Hash aset should deduplicate non tainted string — chopraanmol1@...
Issue #15251 has been updated by chopraanmol1 (Anmol Chopra).
3 messages
2018/10/25
[#89583] [PATCH] vm_trace.c (postponed_job_register): only hit main thread — Eric Wong <normalperson@...>
@hsbt: I post here on ruby-core because I hit errors with
5 messages
2018/10/27
[#89584] Re: [PATCH] vm_trace.c (postponed_job_register): only hit main thread
— Koichi Sasada <ko1@...>
2018/10/27
thank you for you patch.
[#89590] Re: [PATCH] vm_trace.c (postponed_job_register): only hit main thread
— Eric Wong <normalperson@...>
2018/10/28
Koichi Sasada <ko1@atdot.net> wrote:
[#89621] [Ruby trunk Bug#14867] Process.wait can wait for MJIT compiler process — Greg.mpls@...
Issue #14867 has been updated by MSP-Greg (Greg L).
4 messages
2018/10/29
[#89622] Re: [Ruby trunk Bug#14867] Process.wait can wait for MJIT compiler process
— Eric Wong <normalperson@...>
2018/10/29
Greg.mpls@gmail.com wrote:
[#89627] [Ruby trunk Bug#14867] Process.wait can wait for MJIT compiler process — takashikkbn@...
Issue #14867 has been updated by k0kubun (Takashi Kokubun).
3 messages
2018/10/30
[#89654] [Ruby trunk Bug#14867] Process.wait can wait for MJIT compiler process — takashikkbn@...
Issue #14867 has been updated by k0kubun (Takashi Kokubun).
4 messages
2018/10/31
[#89655] Re: [Ruby trunk Bug#14867] Process.wait can wait for MJIT compiler process
— Eric Wong <normalperson@...>
2018/10/31
takashikkbn@gmail.com wrote:
[ruby-core:89416] [Ruby trunk Feature#14609] `Kernel#p` without args shows the receiver
From:
zverok.offline@...
Date:
2018-10-16 11:13:19 UTC
List:
ruby-core #89416
Issue #14609 has been updated by zverok (Victor Shepelev).
@docx That are pretty interesting comparison with Elixir!
In fact, what the examples show (to me) is a need for more powerful partial application of procs. E.g. what would be a parity for Elixir is something like...
```ruby
def p_with_label(label, obj)
puts "#{label}#{obj.inspect}"
end
[1, 2, 3]
.tap(&method(:p_with_label).curry['before: '])
.map { |x| x * 2 }
.tap(&method(:p_with_label).curry['after: '])
.sum
```
This example already works, yet doesn't look VERY expressive, to be honest. I see two pretty different solutions to the problem:
First is **core**. Considering the shorten of `&method(:name)` is discussed for ages (and _almost_ agreed to be `&:.name`), it could be discussed on addition of more powerful partial application than current (mostly unusable) `Proc#curry` to language core. The result may look somewhat like (fantasizing)...
```ruby
[1, 2, 3]
.tap(&:.p.with('before: '))
.map { |x| x * 2 }
.tap(&:.p.with('after: '))
.sum
```
The second one is **rise of proc-producing libraries:**
```ruby
module Functional
module_function
def inspect(label:)
->(obj) { puts "#{label}#{obj.inspect}" }
end
end
[1, 2, 3]
.tap(&Functional.inspect(label: 'before: '))
.map { |x| x * 2 }
.tap(&Functional.inspect(label: 'after: '))
.sum
```
----------------------------------------
Feature #14609: `Kernel#p` without args shows the receiver
https://bugs.ruby-lang.org/issues/14609#change-74455
* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 2.6
----------------------------------------
# Abstract
`Kernel#p(obj)` prints obj as `inspect`ed.
How about to show the receiver if an argument is not given?
# Background
We recently introduce `yield_self` which encourages block chain.
https://zverok.github.io/blog/2018-01-24-yield_self.html
Quoted from this article, we can write method chain with blocks:
```
construct_url
.yield_self { |url| Faraday.get(url) }.body
.yield_self { |response| JSON.parse(response) }
.dig('object', 'id')
.yield_self { |id| id || '<undefined>' }
.yield_self { |id| "server:#{id}" }
```
There is a small problem at debugging.
If we want to see the middle values in method/block chain, we need to insert `tap{|e| p e}`.
With above example,
```
construct_url
.yield_self { |url| Faraday.get(url) }.body
.yield_self { |response| JSON.parse(response) }.tap{|e| p e} # debug print
.dig('object', 'id')
.yield_self { |id| id || '<undefined>' }.tap{|e| p e} # debug print
.yield_self { |id| "server:#{id}" }
```
# Proposal
`obj.p` shows same as `p(obj)`.
We can replace
`block{...}.tap{|e| p e}`
to
`block{...}.p`
For above example, we can simply add `.p` at the end of line:
```
construct_url
.yield_self { |url| Faraday.get(url) }.body
.yield_self { |response| JSON.parse(response) }.p # debug print
.dig('object', 'id')
.yield_self { |id| id || '<undefined>' }.p # debug print
.yield_self { |id| "server:#{id}" }
```
# Compatibility issue
(1) Shorthand for `nil`
This spec change can introduce compatibility issue because `p` returns `nil` and do not output anything.
That is to say, `p` is shorthand of `nil`. Some code-golfers use it.
Maybe we can ignore them :p
(2) make public method
`Kernel#p` is private method, so if we typo `obj.x` to `obj.p` (not sure how it is feasible), it will be `NoMethodError` because of visibility.
We need to change this behavior.
# Note
## Past proposal and discussion
Endoh-san proposed same idea 10+ years ago [ruby-dev:29736] in Japanese.
I think we should revisit this idea because of `yield_self` introduction.
At this thread, Matz said "simple `p` shows `p(self)`, it is not clear".
[ruby-dev:30903]
```
p
はどう動くのかとか(p selfと同じ、は変な気が)
self.p(obj)
はどうなのかとか。その辺が解決(納得)できたら、ということで。
```
English translation:
```
What the behavior of (I feel strange that it is similar to `p(self)`):
p
What happen on
self.p(obj)
```
## pp
If this proposal is accepted, we also need to change `pp` behavior.
## gems
`tapp` method is provided by gem.
https://github.com/esminc/tapp
I'd thought to propose this method into core. But I found that `p` is more shorter than `tapp`.
Disadvantage is `p` is too short and difficult to grep.
--
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>