[#65451] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...
Issue #10333 has been updated by Koichi Sasada.
9 messages
2014/10/07
[#65458] Re: [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string
— Eric Wong <normalperson@...>
2014/10/07
[email protected] wrote:
[#65502] Re: [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string
— Eric Wong <normalperson@...>
2014/10/08
Eric Wong <[email protected]> wrote:
[#65538] Re: [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string
— Eric Wong <normalperson@...>
2014/10/09
Eric Wong <[email protected]> wrote:
[#65549] Re: [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string
— SASADA Koichi <ko1@...>
2014/10/09
On 2014/10/09 11:04, Eric Wong wrote:
[#65551] Re: [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string
— Eric Wong <normalperson@...>
2014/10/09
SASADA Koichi <[email protected]> wrote:
[#65453] [ruby-trunk - Feature #10328] [PATCH] make OPT_SUPPORT_JOKE a proper VM option — ko1@...
Issue #10328 has been updated by Koichi Sasada.
3 messages
2014/10/07
[#65559] is there a name for this? — Xavier Noria <fxn@...>
When describing stuff about constants (working in their guide), you often
7 messages
2014/10/09
[#65560] Re: is there a name for this?
— Nobuyoshi Nakada <nobu@...>
2014/10/09
On 2014/10/09 20:41, Xavier Noria wrote:
[#65561] Re: is there a name for this?
— Xavier Noria <fxn@...>
2014/10/09
On Thu, Oct 9, 2014 at 1:59 PM, Nobuyoshi Nakada <[email protected]> wrote:
[#65566] [ruby-trunk - Feature #10351] [Open] [PATCH] prevent CVE-2014-6277 — shyouhei@...
Issue #10351 has been reported by Shyouhei Urabe.
3 messages
2014/10/09
[#65741] Re: [ruby-cvs:55121] normal:r47971 (trunk): test/ruby/test_rubyoptions.rb: fix race — Nobuyoshi Nakada <nobu@...>
On 2014/10/16 10:10, [email protected] wrote:
5 messages
2014/10/16
[#65742] Re: [ruby-cvs:55121] normal:r47971 (trunk): test/ruby/test_rubyoptions.rb: fix race
— Eric Wong <normalperson@...>
2014/10/16
Nobuyoshi Nakada <[email protected]> wrote:
[#65750] Re: [ruby-cvs:55121] normal:r47971 (trunk): test/ruby/test_rubyoptions.rb: fix race
— Tanaka Akira <akr@...>
2014/10/16
2014-10-16 12:48 GMT+09:00 Eric Wong <[email protected]>:
[#65753] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...
Issue #10333 has been updated by Koichi Sasada.
3 messages
2014/10/16
[#65818] [ruby-trunk - Feature #10351] [PATCH] prevent CVE-2014-6277 — shyouhei@...
Issue #10351 has been updated by Shyouhei Urabe.
3 messages
2014/10/20
[ruby-core:65332] [ruby-trunk - Feature #10095] Object#as
From:
brandon_weaver@...
Date:
2014-10-01 00:13:50 UTC
List:
ruby-core #65332
Issue #10095 has been updated by Brandon Weaver.
Andrew Vit wrote:
> This feature also looks a lot like a pipeline.
>
> Here are some examples how people implemented that before, either using simple blocks or more complex generator/consumer queues:
>
> https://gist.github.com/pcreux/2f87847e5e4aad37db02
> https://github.com/meh/ruby-thread#pipe
> http://pragdave.me/blog/2007/12/30/pipelines-using-fibers-in-ruby-19/
>
> For the purposes of this feature the method name could be something like `pipe_to`. (Hopefully that's not confusing with IO.pipe.)
>
> Eventually, this could be an opportunity for pipelines as a first-class concept with better syntax sugar, similar to one of the examples above, or like Elixir (`|>`). Someone else can make a good proposal for that, but to think ahead maybe this method name should express "pipe" as part of its name.
>
> Here is my own naive example:
>
> ~~~
> class Object
> def | other
> case other
> when Proc
> if self.is_a?(Proc)
> proc { |input| other.call( self.call(input) ) }
> else
> other.call(self)
> end
> else
> super
> end
> end
> end
>
> "ruby" |-> r { r.upcase }
> #=> "RUBY"
>
> pipeline = &:upcase | &:reverse
> "ruby" | pipeline
> #=> "YRUB"
> ~~~
related: #10308
I've actually done it too before, I just literally named it pipe:
https://github.com/baweaver/pipeable
or Stream which was something to the same idea:
https://github.com/baweaver/streamable
Either way this has been hacked to death in multiple places. I'd think that just going for an Elixir like pipe would be the cleanest implementation honestly.
----------------------------------------
Feature #10095: Object#as
https://bugs.ruby-lang.org/issues/10095#change-49146
* Author: Akira Matsuda
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
We've had so many times of feature requests for a method similar to Object#tap that doesn't return self but returns the given block's execution result (e.g. #7388, #6684, #6721 ).
I'm talking about something like this in Ruby of course:
Object.class_eval { def as() yield(self) end }
IIRC Matz is not against introducing this feature but he didn't like any of the names proposed in the past, such as embed, do, identity, ergo, reference, yield_self, itself, apply, map, tap!, etc.
So, let us propose a new name, Object#as today.
It's named from the aspect of the feature that it gives the receiver a new name "as" a block local variable.
For instance, the code reads so natural and intuitive like this:
(1 + 2 + 3 + 4).as {|x| x ** 2}
=> 100
Array.new.as {|a| a << 1; a << 2}
=> [1, 2]
---Files--------------------------------
itself-block.patch (1.35 KB)
--
https://bugs.ruby-lang.org/