[#75225] [Ruby trunk Feature#12324] Support OpenSSL 1.1.0 (and drop support for 0.9.6/0.9.7) — k@...
Issue #12324 has been reported by Kazuki Yamaguchi.
6 messages
2016/04/27
[#78693] Re: [Ruby trunk Feature#12324] Support OpenSSL 1.1.0 (and drop support for 0.9.6/0.9.7)
— Eric Wong <normalperson@...>
2016/12/17
k@rhe.jp wrote:
[#78701] Re: [Ruby trunk Feature#12324] Support OpenSSL 1.1.0 (and drop support for 0.9.6/0.9.7)
— Kazuki Yamaguchi <k@...>
2016/12/17
On Sat, Dec 17, 2016 at 01:31:12AM +0000, Eric Wong wrote:
[#78702] Re: [Ruby trunk Feature#12324] Support OpenSSL 1.1.0 (and drop support for 0.9.6/0.9.7)
— Eric Wong <normalperson@...>
2016/12/17
Kazuki Yamaguchi <k@rhe.jp> wrote:
[ruby-core:74945] [Ruby trunk Feature#12281] Allow lexically scoped use of refinements with `using {}` block syntax
From:
6ftdan@...
Date:
2016-04-14 03:56:11 UTC
List:
ruby-core #74945
Issue #12281 has been updated by Daniel P. Clark.
I would also like the block for `using` to have access to local variables.
~~~ruby
def example(thing)
using MyCapitalize do
thing.my_capitalize
end
end
example "hello"
# => "Hello"
~~~
----------------------------------------
Feature #12281: Allow lexically scoped use of refinements with `using {}` block syntax
https://bugs.ruby-lang.org/issues/12281#change-58073
* Author: Daniel P. Clark
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
In Ruby 2.2.3 a refinement could be used in a begin/end block.
~~~ruby
module Moo
refine Fixnum do
def to_s
"moo"
end
end
end
begin # valid Ruby 2.2.3 and NOT Ruby 2.3
using Moo
1.to_s
end
# => "moo"
~~~
Since this use case has been removed I would like to propose an alternative.
~~~ruby
using Moo do
1.to_s
end
# => "moo"
~~~
I would like to propose allowing refinements to take a block and perform the refinement within the block and work just as if it were in it's own lexically scoped class.
I've been writing a lot of Rust lately and have found that their way of implementing Traits is just like Ruby's refinements except for that you can use Rust's version of refinements anywhere. Since Ruby's implementation is strictly lexically scoped I merely suggest a block syntax for `using` to allow greater expansion of refinements.
~~~rust
// Rust
impl MyCapitalize for String {
fn my_capitalize(&self) -> Self {
// code here
}
}
use MyCapitalize;
String::from("hello").my_capitalize()
~~~
Rust lets you use the "refinement" of the trait implementation anywhere you use `use` just like Ruby's `using`. But currently Ruby restricts where `using` can be used. I would like that restriction to be lifted by allowing `using` to take a block.
~~~ruby
# Ruby
module MyCapitalize
refine String do
def my_capitalize
# code here
end
end
end
using MyCapitalize do
"hello".my_capitalize
end
# => "Hello"
~~~
This way we keep Ruby's strict lexical scope behavior and at the same time allow refinement usage anywhere we need it.
--
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>