[#100309] How to use backport custom field — Jun Aruga <jaruga@...>
Please allow my ignorance.
9 messages
2020/10/06
[#100310] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
IkJhY2twb3J0IGN1c3RvbSBmaWVsZCIgaXMgb25seSBhdmFpbGFibGUgZm9yIHRpY2tldHMgd2hv
[#100311] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/06
On Tue, Oct 6, 2020 at 4:44 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[#100314] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
VGhhbmsgeW91IGZvciBjb25maXJtYXRpb24uCkkgY2hlY2tlZCBhZ2FpbiBhbmQgdG8gZWRpdCBi
[#100322] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Tue, Oct 6, 2020 at 7:25 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[#100326] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/07
SSBhZGRlZCB5b3UgdG8gIlJlcG9ydGVyIiByb2xlIGluIHRoZSBwcm9qZWN0CgoyMDIw5bm0MTDm
[#100327] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Wed, Oct 7, 2020 at 1:42 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[ruby-core:100277] [Ruby master Feature#17145] Ractor-aware `Object#deep_freeze`
From:
shatrov@...
Date:
2020-10-02 08:44:03 UTC
List:
ruby-core #100277
Issue #17145 has been updated by kirs (Kir Shatrov).
I'd really like to support this change for reasons I've describe in https://bugs.ruby-lang.org/issues/17180
We can take something as simple as `URI::parse("http://example.com")` as an example. Right now that can't be used from a Ractor because `URI::parse` refers to a few internal constants like `URI::RFC3986_PARSER` that are not frozen (and thus not sharable).
If we went with an explicit `deep_freeze` we might need to update all those constants like `URI::RFC3986_PARSER` in the standard library to be also call `deep_freeze`. That doesn't have to be a bad thing but something to be aware of.
marcandre (Marc-Andre Lafortune) wrote:
> I'd like to propose `Object#deep_freeze`:
>
> Freezes recursively the contents of the receiver (by calling `deep_freeze`) and
> then the receiver itself (by calling `freeze`).
> Values that are shareable via `Ractor` (e.g. classes) are never frozen this way.
>
> ```ruby
> # freezes recursively:
> ast = [:hash, [:pair, [:str, 'hello'], [:sym, :world]]].deep_freeze
> ast.dig(1, 1) # => [:str, 'hello']
> ast.dig(1, 1).compact! # => FrozenError
>
> # does not freeze classes:
> [[String]].deep_freeze
> String.frozen? # => false
>
> # calls `freeze`:
> class Foo
> def freeze
> build_cache!
> puts "Ready for freeze"
> super
> end
> # ...
> end
> [[[Foo.new]]].deep_freeze # => Outputs "Ready for freeze"
> ```
>
>
> I think a variant `deep_freeze!` that raises an exception if the result isn't Ractor-shareable would be useful too:
>
> ```ruby
> class Fire
> def freeze
> # do not call super
> end
> end
>
> x = [Fire.new]
> x.deep_freeze! # => "Could not be deeply-frozen: #<Fire:0x00007ff151994748>"
> ```
----------------------------------------
Feature #17145: Ractor-aware `Object#deep_freeze`
https://bugs.ruby-lang.org/issues/17145#change-87864
* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
----------------------------------------
I'd like to propose `Object#deep_freeze`:
Freezes recursively the contents of the receiver (by calling `deep_freeze`) and
then the receiver itself (by calling `freeze`).
Values that are shareable via `Ractor` (e.g. classes) are never frozen this way.
```ruby
# freezes recursively:
ast = [:hash, [:pair, [:str, 'hello'], [:sym, :world]]].deep_freeze
ast.dig(1, 1) # => [:str, 'hello']
ast.dig(1, 1).compact! # => FrozenError
# does not freeze classes:
[[String]].deep_freeze
String.frozen? # => false
# calls `freeze`:
class Foo
def freeze
build_cache!
puts "Ready for freeze"
super
end
# ...
end
[[[Foo.new]]].deep_freeze # => Outputs "Ready for freeze"
```
I think a variant `deep_freeze!` that raises an exception if the result isn't Ractor-shareable would be useful too:
```ruby
class Fire
def freeze
# do not call super
end
end
x = [Fire.new]
x.deep_freeze! # => "Could not be deeply-frozen: #<Fire:0x00007ff151994748>"
```
--
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>