ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:55521] [ruby-trunk - Feature #8536][Open] Implement is_numeric? family of methods
@ 2013-06-17  3:31 wardrop (Tom Wardrop)
  2013-07-31 23:29 ` [ruby-core:56287] [ruby-trunk - Feature #8536] " phluid61 (Matthew Kerwin)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: wardrop (Tom Wardrop) @ 2013-06-17  3:31 UTC (permalink / raw
  To: ruby-core


Issue #8536 has been reported by wardrop (Tom Wardrop).

----------------------------------------
Feature #8536: Implement is_numeric? family of methods
https://bugs.ruby-lang.org/issues/8536

Author: wardrop (Tom Wardrop)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: current: 2.1.0


=begin
I think Ruby is in dire need of a convenient method for determining whether a string can be safely converted to a number. It's a trivial problem, but with no trivial solution. The most common methods include using regex, or trying to convert the value to the desired type, rescuring any exceptions that are raised. These are not desirable by any means.

I propose a number of new methods be added, either to each of the number classes such as (({Integer.is_integer?})) and (({Numeric.is_numeric?})), to a single parent such as Numeric. For convenience, corresponding methods may also be added to the String class. The methods I propose are...

* is_numeric?
* is_integer?
* is_float?
* is_rationale?

With the exception of numeric, if each of the other methods return true, that value should be safe to use with the corresponding (({Integer("5")})) style methods, and (({to_i})) methods. These boolean methods should behave like the (({Integer("5")})), in that they should disregard/strip whitespace for example.

I think it'd make a nice feature enhancement to Ruby 2.1.
=end


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:56287] [ruby-trunk - Feature #8536] Implement is_numeric? family of methods
  2013-06-17  3:31 [ruby-core:55521] [ruby-trunk - Feature #8536][Open] Implement is_numeric? family of methods wardrop (Tom Wardrop)
@ 2013-07-31 23:29 ` phluid61 (Matthew Kerwin)
  2013-08-01  0:33 ` [ruby-core:56292] " nobu (Nobuyoshi Nakada)
  2013-10-01  8:00 ` [ruby-core:57524] [ruby-trunk - Feature #8536][Assigned] " naruse (Yui NARUSE)
  2 siblings, 0 replies; 4+ messages in thread
From: phluid61 (Matthew Kerwin) @ 2013-07-31 23:29 UTC (permalink / raw
  To: ruby-core


Issue #8536 has been updated by phluid61 (Matthew Kerwin).


=begin
I am +1, if you change (({is_rationale?})) to (({is_rational?}))

Implementation question: is it reasonable to refactor rb_cstr_to_inum (etc.) to conditionally not perform the Integer object allocation?
=end

----------------------------------------
Feature #8536: Implement is_numeric? family of methods
https://bugs.ruby-lang.org/issues/8536#change-40778

Author: wardrop (Tom Wardrop)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: current: 2.1.0


=begin
I think Ruby is in dire need of a convenient method for determining whether a string can be safely converted to a number. It's a trivial problem, but with no trivial solution. The most common methods include using regex, or trying to convert the value to the desired type, rescuring any exceptions that are raised. These are not desirable by any means.

I propose a number of new methods be added, either to each of the number classes such as (({Integer.is_integer?})) and (({Numeric.is_numeric?})), to a single parent such as Numeric. For convenience, corresponding methods may also be added to the String class. The methods I propose are...

* is_numeric?
* is_integer?
* is_float?
* is_rationale?

With the exception of numeric, if each of the other methods return true, that value should be safe to use with the corresponding (({Integer("5")})) style methods, and (({to_i})) methods. These boolean methods should behave like the (({Integer("5")})), in that they should disregard/strip whitespace for example.

I think it'd make a nice feature enhancement to Ruby 2.1.
=end


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:56292] [ruby-trunk - Feature #8536] Implement is_numeric? family of methods
  2013-06-17  3:31 [ruby-core:55521] [ruby-trunk - Feature #8536][Open] Implement is_numeric? family of methods wardrop (Tom Wardrop)
  2013-07-31 23:29 ` [ruby-core:56287] [ruby-trunk - Feature #8536] " phluid61 (Matthew Kerwin)
@ 2013-08-01  0:33 ` nobu (Nobuyoshi Nakada)
  2013-10-01  8:00 ` [ruby-core:57524] [ruby-trunk - Feature #8536][Assigned] " naruse (Yui NARUSE)
  2 siblings, 0 replies; 4+ messages in thread
From: nobu (Nobuyoshi Nakada) @ 2013-08-01  0:33 UTC (permalink / raw
  To: ruby-core


Issue #8536 has been updated by nobu (Nobuyoshi Nakada).


There is no "is_"+adjective+"?" built-in methods.
And check-then-convert seems redundant.
----------------------------------------
Feature #8536: Implement is_numeric? family of methods
https://bugs.ruby-lang.org/issues/8536#change-40783

Author: wardrop (Tom Wardrop)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: current: 2.1.0


=begin
I think Ruby is in dire need of a convenient method for determining whether a string can be safely converted to a number. It's a trivial problem, but with no trivial solution. The most common methods include using regex, or trying to convert the value to the desired type, rescuring any exceptions that are raised. These are not desirable by any means.

I propose a number of new methods be added, either to each of the number classes such as (({Integer.is_integer?})) and (({Numeric.is_numeric?})), to a single parent such as Numeric. For convenience, corresponding methods may also be added to the String class. The methods I propose are...

* is_numeric?
* is_integer?
* is_float?
* is_rationale?

With the exception of numeric, if each of the other methods return true, that value should be safe to use with the corresponding (({Integer("5")})) style methods, and (({to_i})) methods. These boolean methods should behave like the (({Integer("5")})), in that they should disregard/strip whitespace for example.

I think it'd make a nice feature enhancement to Ruby 2.1.
=end


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:57524] [ruby-trunk - Feature #8536][Assigned] Implement is_numeric? family of methods
  2013-06-17  3:31 [ruby-core:55521] [ruby-trunk - Feature #8536][Open] Implement is_numeric? family of methods wardrop (Tom Wardrop)
  2013-07-31 23:29 ` [ruby-core:56287] [ruby-trunk - Feature #8536] " phluid61 (Matthew Kerwin)
  2013-08-01  0:33 ` [ruby-core:56292] " nobu (Nobuyoshi Nakada)
@ 2013-10-01  8:00 ` naruse (Yui NARUSE)
  2 siblings, 0 replies; 4+ messages in thread
From: naruse (Yui NARUSE) @ 2013-10-01  8:00 UTC (permalink / raw
  To: ruby-core


Issue #8536 has been updated by naruse (Yui NARUSE).

Status changed from Open to Assigned
Assignee set to matz (Yukihiro Matsumoto)
Target version changed from current: 2.1.0 to next minor


----------------------------------------
Feature #8536: Implement is_numeric? family of methods
https://bugs.ruby-lang.org/issues/8536#change-42138

Author: wardrop (Tom Wardrop)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: next minor


=begin
I think Ruby is in dire need of a convenient method for determining whether a string can be safely converted to a number. It's a trivial problem, but with no trivial solution. The most common methods include using regex, or trying to convert the value to the desired type, rescuring any exceptions that are raised. These are not desirable by any means.

I propose a number of new methods be added, either to each of the number classes such as (({Integer.is_integer?})) and (({Numeric.is_numeric?})), to a single parent such as Numeric. For convenience, corresponding methods may also be added to the String class. The methods I propose are...

* is_numeric?
* is_integer?
* is_float?
* is_rationale?

With the exception of numeric, if each of the other methods return true, that value should be safe to use with the corresponding (({Integer("5")})) style methods, and (({to_i})) methods. These boolean methods should behave like the (({Integer("5")})), in that they should disregard/strip whitespace for example.

I think it'd make a nice feature enhancement to Ruby 2.1.
=end


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-01  8:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-17  3:31 [ruby-core:55521] [ruby-trunk - Feature #8536][Open] Implement is_numeric? family of methods wardrop (Tom Wardrop)
2013-07-31 23:29 ` [ruby-core:56287] [ruby-trunk - Feature #8536] " phluid61 (Matthew Kerwin)
2013-08-01  0:33 ` [ruby-core:56292] " nobu (Nobuyoshi Nakada)
2013-10-01  8:00 ` [ruby-core:57524] [ruby-trunk - Feature #8536][Assigned] " naruse (Yui NARUSE)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).