[#101174] [Ruby master Bug#17359] Ractor copy mode is not Ractor-safe — marcandre-ruby-core@...

Issue #17359 has been reported by marcandre (Marc-Andre Lafortune).

17 messages 2020/12/01

[#101217] [Ruby master Feature#17363] Timeouts — marcandre-ruby-core@...

Issue #17363 has been reported by marcandre (Marc-Andre Lafortune).

19 messages 2020/12/03

[#101250] [Ruby master Bug#17369] Introduce non-blocking `Process.wait`, `Kernel.system` and related methods. — samuel@...

Issue #17369 has been reported by ioquatix (Samuel Williams).

12 messages 2020/12/05

[#101276] [Ruby master Bug#17373] Ruby 3.0 is slower at Discourse bench than Ruby 2.7 — sam.saffron@...

Issue #17373 has been reported by sam.saffron (Sam Saffron).

11 messages 2020/12/07

[#101278] [Ruby master Bug#17374] Refined methods aren't visible from a refinementRefinements that include/prepend module — marcandre-ruby-core@...

Issue #17374 has been reported by marcandre (Marc-Andre Lafortune).

17 messages 2020/12/07

[#101317] [Ruby master Feature#17378] Ractor#receive with filtering like other actor langauge — ko1@...

Issue #17378 has been reported by ko1 (Koichi Sasada).

9 messages 2020/12/08

[#101343] [Ruby master Bug#17382] Segfault in String#inspect — lionel.perrin@...

Issue #17382 has been reported by lionelperrin (Lionel Perrin).

10 messages 2020/12/09

[#101381] [Ruby master Bug#17385] Test failures on gcc 11 — jaruga@...

Issue #17385 has been reported by jaruga (Jun Aruga).

18 messages 2020/12/10

[#101458] [Ruby master Bug#17394] TCPServer is not thread safe on win32 — aladjev.andrew@...

Issue #17394 has been reported by puchuu (Andrew Aladjev).

9 messages 2020/12/14

[#101472] [Ruby master Feature#17397] shareable_literal_constant should check at runtime, not at parse time — marcandre-ruby-core@...

Issue #17397 has been reported by marcandre (Marc-Andre Lafortune).

10 messages 2020/12/16

[#101475] [Ruby master Bug#17398] SyntaxError in endless method — zverok.offline@...

Issue #17398 has been reported by zverok (Victor Shepelev).

15 messages 2020/12/16

[#101477] [Ruby master Misc#17399] Are endless methods experimental? — zverok.offline@...

Issue #17399 has been reported by zverok (Victor Shepelev).

13 messages 2020/12/16

[#101480] [Ruby master Bug#17400] Incorrect character downcase for Greek Sigma — xfalcox@...

SXNzdWUgIzE3NDAwIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHhmYWxjb3ggKFJhZmFlbCBTaWx2YSku

10 messages 2020/12/16

[#101513] [Ruby master Bug#17405] irb ---nomultiline gets exception when output contains some non-ascii characters — rsharman@...

SXNzdWUgIzE3NDA1IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHJzaGFybWFuIChSaWNoYXJkIFNoYXJt

8 messages 2020/12/18

[#101534] [Ruby master Bug#17409] Endless range of dates stuck on include? when miss — sergey.gnuskov@...

Issue #17409 has been reported by gsmetal (Sergey G).

9 messages 2020/12/19

[#101546] [Ruby master Bug#17411] Syntax error with . in pattern — zverok.offline@...

Issue #17411 has been reported by zverok (Victor Shepelev).

10 messages 2020/12/19

[#101598] [Ruby master Bug#17420] Unsafe mutation of $" when doing non-RubyGems require in Ractor — eregontp@...

Issue #17420 has been reported by Eregon (Benoit Daloze).

12 messages 2020/12/21

[#101635] [Ruby master Bug#17428] Method#inspect bad output for class methods — marcandre-ruby-core@...

Issue #17428 has been reported by marcandre (Marc-Andre Lafortune).

13 messages 2020/12/23

[#101639] [Ruby master Bug#17429] Prohibit include/prepend in refinement modules — shugo@...

Issue #17429 has been reported by shugo (Shugo Maeda).

32 messages 2020/12/23

[#101707] [Ruby master Feature#17472] HashWithIndifferentAccess like Hash extension — naruse@...

Issue #17472 has been reported by naruse (Yui NARUSE).

31 messages 2020/12/26

[#101710] [Ruby master Feature#17473] Make Pathname to embedded class of Ruby — hsbt@...

Issue #17473 has been reported by hsbt (Hiroshi SHIBATA).

28 messages 2020/12/26

[#101719] [Ruby master Feature#17474] Interpreting constants at compile time — jzakiya@...

Issue #17474 has been reported by jzakiya (Jabari Zakiya).

23 messages 2020/12/26

[#101735] [Ruby master Misc#17480] DevelopersMeeting20210113Japan — mame@...

Issue #17480 has been reported by mame (Yusuke Endoh).

12 messages 2020/12/27

[#101790] [Ruby master Bug#17486] Build fails on darwin due to libtool being removed — dark.panda@...

Issue #17486 has been reported by dark.panda (J Smith).

11 messages 2020/12/28

[#101794] [Ruby master Bug#17488] Regression in Ruby 3: Hash#key? is non-deterministic when argument uses DelegateClass — myron.marston@...

Issue #17488 has been reported by myronmarston (Myron Marston).

11 messages 2020/12/28

[#101809] [Ruby master Feature#17490] Rename RubyVM::MJIT to RubyVM::JIT — takashikkbn@...

Issue #17490 has been reported by k0kubun (Takashi Kokubun).

15 messages 2020/12/30

[#101838] [Ruby master Feature#17496] Add constant Math::TAU — jzakiya@...

Issue #17496 has been reported by jzakiya (Jabari Zakiya).

32 messages 2020/12/31

[#101840] [Ruby master Bug#17497] Ractor performance issue — marcandre-ruby-core@...

SXNzdWUgIzE3NDk3IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IG1hcmNhbmRyZSAoTWFyYy1BbmRyZSBM

21 messages 2020/12/31

[ruby-core:101232] Re: [Ruby master Feature#17342] Hash#fetch_set

From: Austin Ziegler <halostatue@...>
Date: 2020-12-03 22:57:38 UTC
List: ruby-core #101232
I=E2=80=99m mostly doing Elixir these days, and one of the caching modules =
I use
has as its main interface `fetch_or_set`, so I think that=E2=80=99s the bes=
t choice
if this is present. On the other hand, Nobu=E2=80=99s refinement implementa=
tion
looks pretty good (and I say this not using refinements yet, even though
they=E2=80=99ve been around for a while).

-a
```

On Thu, Dec 3, 2020 at 2:13 PM <eregontp@gmail.com> wrote:

> Issue #17342 has been updated by Eregon (Benoit Daloze).
>
>
> shyouhei (Shyouhei Urabe) wrote in #note-13:
> > Yes I=E2=80=99m quite sure he is dead serious.  There  are idiots who w=
rite
> nonsense codes.  As a language ruby has to be fool-proof.
>
> I think such semantics (calling #hash only once) could be part of the
> method documentation.
> OTOH calling `#hash` twice is probably not very expensive, and for some
> cases (e.g. Integer, String) can be optimized by a JIT or by memoizing th=
e
> hash on the instance.
>
> I don't like the name `fetch_set` much (does it fetch a Set?).
> I think `fetch_or_set` or `cache` are better.
>
> ----------------------------------------
> Feature #17342: Hash#fetch_set
> https://bugs.ruby-lang.org/issues/17342#change-88908
>
> * Author: MaxLap (Maxime Lapointe)
> * Status: Open
> * Priority: Normal
> ----------------------------------------
> I would like to propose adding the `fetch_set` method to `Hash`. It
> behaves just like `fetch`, but when using the default value (2nd argument
> or the block), it also sets the value in the Hash for the given key.
>
> We often use the pattern `cache[key] ||=3D calculation`. This pattern
> however has a problem when the calculation could return false or nil, as =
in
> those case, the calculation is repeated each time.
>
> I believe the best practice in that case is:
>
> ```ruby
> cache.fetch(key) { cache[key] =3D calculation }
> ```
>
> With my suggestion, it would be:
>
> ```ruby
> cache.fetch_set(key) { calculation }
> ```
>
> In these examples, each part is very short, so the `fetch` case is still
> clean. But as each part gets longer, the need to repeat cache[key] become=
s
> more friction.
>
> Here is a more realistic example:
>
> ```ruby
> # Also using the key argument to the block to avoid repeating the
> # long symbol, adding some indirection
> RequestStore.store.fetch(:monitor_value_is_delayed?) do |key|
>   RequestStore.store[key] =3D !MonitorValue.where('date >=3D ?', Time.now=
 -
> 5.minutes).exists?
> end
>
> RequestStore.store.fetch_set(:monitor_value_is_delayed?) do
>   !MonitorValue.where('date >=3D ?', Time.now - 5.minutes).exists?
> end
> ```
>
> There is a precedent for such a method: Python has it, but with a quite
> confusing name: `setdefault(key, default_value)`. This does not set a
> default for the whole dictionary as the name would make you think, it
> really just does what is proposed here.
> https://docs.python.org/3/library/stdtypes.html#dict.setdefault
>
>
>
> --
> https://bugs.ruby-lang.org/
>
> Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=3Dunsubscrib=
e>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
>


--=20
Austin Ziegler =E2=80=A2 halostatue@gmail.com =E2=80=A2 austin@halostatue.c=
a
http://www.halostatue.ca/ =E2=80=A2 http://twitter.com/halostatue

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread