[ruby-core:77683] [Ruby trunk Bug#11929] No programatic way to check ability to dup/clone an object

From: duerst@...
Date: 2016-10-20 09:11:57 UTC
List: ruby-core #77683
Issue #11929 has been updated by Martin D端rst.

Assignee set to Yukihiro Matsumoto

I clearly prefer the last proposal (fail silently).

That would make for a much more unified, streamlined protocol, avoiding needless exposition of internals. It would do exactly what dup (and clone) are described to do, namely (pretend to) return a shallow copy.


----------------------------------------
Bug #11929: No programatic way to check ability to dup/clone an object
https://bugs.ruby-lang.org/issues/11929#change-60967

* Author: xavier nayrac
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* ruby -v: ruby 2.3.0dev (2015-12-06 trunk 52904) [i686-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
We can't dup a Fixnum, and it's ok. But I'm wondering 束why is Fixnum saying it can dup?損

~~~
1.respond_to?(:dup) #=> true
~~~

Don't you think that the `dup` method should be undefined in the class Fixnum?

Currently I can do `class Fixnum; undef :dup; end`, but that should be in the core Ruby, isn't it?




-- 
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>

In This Thread

Prev Next