[#100284] [Ruby master Bug#17211] Test failures in ruby2.7.2 and ruby3.0~preview1 — utkarsh@...

Issue #17211 has been reported by utkarsh (Utkarsh Gupta).

10 messages 2020/10/02

[#100301] [Ruby master Feature#17215] Backport for arm64 optimizations that exist for power/x86 — jaruga@...

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

10 messages 2020/10/05

[#100329] [Ruby master Bug#17220] Rails Active Job integration test fails with Ruby 3.0.0 since 2038cc6cab6ceeffef3ec3a765c70ae684f829ed — yasuo.honda@...

Issue #17220 has been reported by yahonda (Yasuo Honda).

28 messages 2020/10/07

[#100332] [Ruby master Bug#17221] Relax the Fiber#transfer's limitation — ko1@...

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

15 messages 2020/10/07

[#100348] [Ruby master Bug#17257] Integer#pow(0, 1) returns 1, which is incorrect — universato@...

Issue #17257 has been reported by universato (Yoshimine Sato).

13 messages 2020/10/09

[#100371] [Ruby master Feature#17260] Promote pattern matching to official feature — kazuki@...

Issue #17260 has been reported by ktsj (Kazuki Tsujimoto).

10 messages 2020/10/11

[#100383] [Ruby master Feature#17261] Software transactional memory (STM) for Threads and Ractors — ko1@...

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

14 messages 2020/10/12

[#100401] [Ruby master Bug#17263] Fiber context switch degrades with number of fibers, limit on number of fibers — ciconia@...

Issue #17263 has been reported by ciconia (Sharon Rosner).

14 messages 2020/10/15

[#100422] [CommonRuby Feature#17265] Add `Bool` module — marcandre-ruby-core@...

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

11 messages 2020/10/19

[#100466] [Ruby master Feature#17273] shareable_constant_value pragma — ko1@...

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

14 messages 2020/10/21

[#100471] [Ruby master Feature#17277] Make Enumerator#with_index yield row and col indices for Matrix — grzegorz.jakubiak@...

Issue #17277 has been reported by greggzst (Grzegorz Jakubiak).

8 messages 2020/10/21

[#100479] [Ruby master Feature#17278] On-demand sharing of constants for Ractor [email protected]

Issue #17278 has been reported by Dan0042 (Daniel DeLorme).

13 messages 2020/10/21

[#100534] [Ruby master Feature#17284] Shareable Proc — ko1@...

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

16 messages 2020/10/25

[#100597] [Ruby master Feature#17288] Optimize __send__ call with a literal method name — muraken@...

Issue #17288 has been reported by mrkn (Kenta Murata).

13 messages 2020/10/27

[#100669] [Ruby master Feature#17295] Feature: Create a directory and file with Pathname#touch — get.codetriage@...

Issue #17295 has been reported by schneems (Richard Schneeman).

9 messages 2020/10/30

[#100673] [Ruby master Feature#17298] Ractor's basket communication APIs — ko1@...

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

15 messages 2020/10/30

[#100675] [Ruby master Misc#17299] DevelopersMeeting20201120Japan — mame@...

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

11 messages 2020/10/31

[ruby-core:100501] [Ruby master Feature#17265] Add `Bool` module

Date: 2020-10-22 12:49:38 UTC
List: ruby-core #100501
Issue #17265 has been updated by Dan0042 (Daniel DeLorme).


mame (Yusuke Endoh) wrote in #note-2:
> BTW, @soutaro (the original author of RBS) is now thinking the redefiniti=
on of `bool` as an alias to `true | false`.

I think that's the better choice. Having `bool` as an alias to `top` is qui=
te confusing. If we want to express that a method returns a truthy/falsy va=
lue, maybe `conditional` or `cond` would be a more meaningful alias for `to=
p`.

----------------------------------------
Feature #17265: Add `Bool` module
https://bugs.ruby-lang.org/issues/17265#change-88121

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
1-line Summary: `rbs` would benefit from the existence of common ancestor `=
Bool` for `TrueClass` and `FalseClass`.

Detail:
Matz: I am aware you rejected a similar request, but could we revisit this =
in light of RBS?

One use case was for an easy way to check for `true` or `false` values, ins=
tead of simply for truthiness (e.g. for data transfer, strict argument chec=
king, testing, etc.)

I believe there's a new use case: `RBS`

In `RBS`, the most used types like `String` and `Integer` have types for "s=
tring-like" and "integer-like" objects: `string` and `integer` (all lowerca=
se).

For example the signature for `Integer#>>` is:

```
def >>: (int) -> Integer
```

It accepts an `Integer` *or an object responding to `to_int`* (summarized b=
y `int`) and returns an `Integer` (and never another class of object respon=
ding to `to_int` or not).

There is a similar idea with boolean values, where a method may accept any =
object and will use it's truthiness, while returning `true | false`. For ex=
ample one of the interface for `Enumerable#all?` should look like:

```
def all?: () { (Elem) -> bool } -> true | false
```

The user supplied block can return any value, and its truthiness (anything =
else than `nil` or `false`) will be used to determine the result of `all?`.=
 That result will be `true | false`, and no other value.

If RBS is to be popular, there will be *many* signatures for such predicate=
s (in builtin Ruby, stdlib, any gems, applications, etc.). I feel the best =
option would be `Bool`, if this would be reflected in Ruby itself.

Proposal: a new global module called `Bool`, without any method of constant=
, included in `TrueClass` and `FalseClass`.

Following reasons for rejection were given at the time:

> many gems and libraries had already introduced Boolean class. I don't wan=
t to break them.

I looked and found the [`bool` gem](https://rubygems.org/gems/bool) that de=
fines a `Bool` module. My proposal is compatible. In any case, this gem loo=
ks abandoned, the author Aslak Helles=F8y doesn't have the code on github, =
the gem has had 7000 downloads in the past 6 years and [has no public rever=
se dependency](https://rubygems.org/gems/bool/reverse_dependencies). It als=
o fails to install on my machine.

I am not aware of incompatibilities.

>  `true` and `false` are the only representative of true-false values. In =
Ruby. `nil` and `false` are falsy values, and everything else is a true val=
ue. There's no meaning for having a superclass of `TrueClass` and `FalseCla=
ss` as `Boolean`.

The proposal is exactly to be able to easily write about this duality of `B=
ool` as having only `true` and `false` as members, and every Ruby object as=
 being implicitly convertible as being truthy or falsy (`bool` in RBS).

Discussion in RBS:
* https://github.com/ruby/rbs/issues/133

Previous feature requests for `Boolean`:
* https://bugs.ruby-lang.org/issues/14224
* https://bugs.ruby-lang.org/issues/12515




-- =

https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread