[#120855] [Ruby master Bug#21104] Net::HTTP connections failing in Ruby >= 3.4.0 on macOS with Happy Eyeballs enabled — "mjt58 (Mike Thompson) via ruby-core" <ruby-core@...>

Issue #21104 has been reported by mjt58 (Mike Thompson).

14 messages 2025/02/01

[#120873] [Ruby master Bug#21111] RbConfig::CONFIG['CXX'] quietly set to "false" when Ruby cannot build C++ programs — "stanhu (Stan Hu) via ruby-core" <ruby-core@...>

Issue #21111 has been reported by stanhu (Stan Hu).

10 messages 2025/02/03

[#120884] [Ruby master Bug#21115] Etc.getgrgid is not Ractor-safe but is marked as such — "Eregon (Benoit Daloze) via ruby-core" <ruby-core@...>

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

7 messages 2025/02/05

[#120897] [Ruby master Bug#21119] Programs containing `Dir.glob` with a thread executing a CPU-heavy task run very slowly. — "genya0407 (Yusuke Sangenya) via ruby-core" <ruby-core@...>

Issue #21119 has been reported by genya0407 (Yusuke Sangenya).

6 messages 2025/02/06

[#121054] [Ruby master Bug#21139] Prism and parse.y parses `it = it` differently — "tompng (tomoya ishida) via ruby-core" <ruby-core@...>

Issue #21139 has been reported by tompng (tomoya ishida).

19 messages 2025/02/14

[#121060] [Ruby master Feature#21140] Add a method to get the address of certain JIT related functions — "tenderlovemaking (Aaron Patterson) via ruby-core" <ruby-core@...>

Issue #21140 has been reported by tenderlovemaking (Aaron Patterson).

23 messages 2025/02/14

[#121077] [Ruby master Misc#21143] Speficy order of execution const_added vs inherited — "fxn (Xavier Noria) via ruby-core" <ruby-core@...>

Issue #21143 has been reported by fxn (Xavier Noria).

15 messages 2025/02/17

[#121142] [Ruby master Misc#21154] Document or change Module#autoload? — "fxn (Xavier Noria) via ruby-core" <ruby-core@...>

Issue #21154 has been reported by fxn (Xavier Noria).

32 messages 2025/02/23

[#121172] [Ruby master Feature#21157] Comparison operator <> — lpogic via ruby-core <ruby-core@...>

SXNzdWUgIzIxMTU3IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGxwb2dpYyAoxYF1a2FzeiBQb21pZXTF

11 messages 2025/02/26

[ruby-core:121131] [Ruby master Feature#21148] Class proposal: IndefiniteNumeric < Numeric

From: "Student (Nathan Zook) via ruby-core" <ruby-core@...>
Date: 2025-02-20 00:37:02 UTC
List: ruby-core #121131
Issue #21148 has been updated by Student (Nathan Zook).


I was not talking about diamond inheritance.  I was talking about

```
Numeric
  Float
  IndefiniteNumeric
    IndefiniteInteger
    IndefiniteFloat
  Integer
...
```

vs

```
Numeric
  Float
    IndefiniteFloat
  IndefiniteNumeric
  Integer
    IndefiniteInteger
...
```

which might break things.

But that discussion is mostly moot when talking `Class` vs `Module`.  "Indefiniteness" is clearly a property that might apply to objects in a way that strongly matches the `Module` concept.  However, as I think about your observation, it seems that I might have been thinking too specifically about the application I was envisioning.

Perhaps my real issue is with the behavior of `Numeric`.  Subclasses of `Numeric` are required to define `#coerce` (and encouraged to implement the arithmetic operators) when in many cases, these objects are numbers with additional context.  Whether we are talking cats in a box, the number of elements in an enumerable, or the change from a purchase, there is a definite value associated with the object, and once we have that, all of these arithmetic operations, to include coercion, are generally set.

As for "necessity", after thirty years, we're probably passed that. :D  For utility, however, I think that this significantly simplifies subclassing `Numeric`.

Assuming this idea is desirable, I see three approaches:

* New module, `Value` with the above method definitions.  This could be included by new subclasses of `Numeric` as desired.
* New subclass of `Numeric`, `Value`, with the above method definitions.
* Modify `Numeric` to check for the presence of `#value` in objects where `#coerce` is not defined, and using the result as described.

The example class `Tally` in the documentation strikes me as wrapping a representation around the whole numbers.  As such, it is natural coerce other values into `Tally` objects, but for the cases I envision, it goes the other way.

The proposed method definitions fill out contract for `Numeric` subclasses.  While it might be reasonable to include these definitions in a class which does not descend from `Numeric`, such a class would not gain the functionality from `Numeric` that these definitions enable.

Between subclassing `Numeric` and changing `Numeric`, I feel nervous about changing behavior, even if it means no raising against code that currently fails a contract.

Also, I am not here to ask for the core team to implement this feature.  I am looking for support for and guidance on a feature before I develop the code and submit it.  (Unless that would be even *more* work for the core team...


----------------------------------------
Feature #21148: Class proposal: IndefiniteNumeric < Numeric
https://bugs.ruby-lang.org/issues/21148#change-112060

* Author: Student (Nathan Zook)
* Status: Open
----------------------------------------
Suppose someone deals five cards face down from a regulation poker deck, and we wish to reason about the number of aces.  We know that that number is one of zero, one, two, three, or four.  Therefore, if someone asks "is this number larger than negative one?", the answer is yes even without ever needing to resolve the actual value.

This proposal is inspired by the proposed `Enumerable::Lazy::Length` class of Kevin Newton in response to #21135 

The `IndefiniteNumeric` class would serve as a base class for such values.  In particular, it relies on a subclass to define `#value`, which returns a definite `Numeric`.

```ruby
class IndefiniteNumeric < Numeric
   def coerce(other) = value.coerce(other)
   def +(other) = value + other
   def -(other) = value - other
   def *(other) = value * other
   def /(other) = value / other
   def <=>(other) = value <=> other
end
```

It is expected that in particular, `<=>` will be overridden for subclasses where `#value` might be slow to return.

Usually, we will know more than just that the value in question is `Numeric`.  It seems appropriate have `IndefiniteInteger` and so forth.  What is not clear to me is if `IndefiniteInteger` should be a subclass of `IndefiniteNumeric` or of `Integer`.  (Such a thing does not appear to be currently possible.)  If subclassing cannot be, what about defining `#kind_of?(Integer)` to be `true`?

Note: with the length of an `Enumerable` as inspiration, I would argue that an `IndefiniteInteger` might actually value to `Float::INFINITY`, so it should NOT define `<=>` against plus or minus `Float::INFINITY`.





-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/


In This Thread