From: Lazaridis Ilias <ilias@lazaridis.com>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:37180] [Ruby 1.9 - Bug #4893] Literal Instantiation breaks Object Model
Date: Fri, 17 Jun 2011 04:00:31 +0900 [thread overview]
Message-ID: <redmine.journal-18024.20110617040030@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-4893.20110617004549@ruby-lang.org
Issue #4893 has been updated by Lazaridis Ilias.
Konstantin Haase wrote:
> On Jun 16, 2011, at 18:42 , Lazaridis Ilias wrote:
> > You should reread the description, experiment a little, and take some time to respond.
>
> To rephrase what Magnus said:
> Where does the object passed to initialize come from? How has that object been initialized?
"How has that 'uninitialized object' been allocated?" would be the question.
String#allocate (either called directly or via String#new)
http://www.ruby-doc.org/core/classes/Class.html#M000178
Those are basics.
The issue is, that after the allocation, the *redefined* initialized should be called.
-
There is a public topic available, with some elaborations:
CORE - Literal Instantiation breaks Object Model
http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/fd00b89dc6d3a7fa#
http://www.ruby-forum.com/topic/1893190#new
----------------------------------------
Bug #4893: Literal Instantiation breaks Object Model
http://redmine.ruby-lang.org/issues/4893
Author: Lazaridis Ilias
Status: Feedback
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 1.9.2
#String2.rb
class String
def initialize(val)
self.replace(val)
puts object_id
end
def my_method_test
'has method <my_method_test>'
end
end
# command line
$ irb
irb(main):001:0> original = String.new("original")
=> "original"
irb(main):002:0> load "String2.rb"
=> true
irb(main):003:0> altered = String.new("altered")
21878604
=> "altered"
irb(main):004:0> altered.my_method_test
=> "has method <my_method_test>"
irb(main):005:0> literal = "literal"
=> "literal"
irb(main):006:0> literal.my_method_test
=> "has method <my_method_test>"
irb(main):007:0>
-
The initialize method is an integral part of the class String.
From the moment that "String2.rb" is loaded, the initialize method of
class String has been validly redefined.
(The behaviour of the String class within the "irb session" is
altered)
The altered initialize method is now an integral part of the class
String.
The altered String object behaves as expected (responds to
"my_method_test, initialized via redefined initialize method).
The String(Literal) object responds to "my_method_test", but it is was
not initialized with the redefined initialize method.
-
The "Literal Instantiation" calls the original (core-C-level) String
initialize method instead of the redefined one (user-language-level).
This *breaks* the object model.
--
http://redmine.ruby-lang.org
next prev parent reply other threads:[~2011-06-16 18:52 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-16 15:46 [ruby-core:37170] [Ruby 1.9 - Bug #4893][Open] Literal Instantiation breaks Object Model Lazaridis Ilias
2011-06-16 16:00 ` [ruby-core:37171] " Magnus Holm
2011-06-16 16:13 ` [ruby-core:37172] [Ruby 1.9 - Bug #4893][Rejected] " Yui NARUSE
2011-06-16 16:42 ` [ruby-core:37173] [Ruby 1.9 - Bug #4893] " Lazaridis Ilias
2011-06-16 16:47 ` [ruby-core:37175] " Haase, Konstantin
2011-06-16 16:45 ` [ruby-core:37174] " Lazaridis Ilias
2011-06-16 17:09 ` [ruby-core:37177] " Magnus Holm
2011-06-16 17:00 ` [ruby-core:37176] [Ruby 1.9 - Bug #4893][Feedback] " Shyouhei Urabe
2011-06-16 17:33 ` [ruby-core:37178] [Ruby 1.9 - Bug #4893] " Lazaridis Ilias
2011-06-16 19:00 ` Lazaridis Ilias [this message]
2011-06-16 22:40 ` [ruby-core:37185] [Ruby 1.9 - Bug #4893][Rejected] " Yukihiro Matsumoto
2011-06-17 16:12 ` [ruby-core:37202] [Ruby 1.9 - Bug #4893] " Lazaridis Ilias
2011-06-20 14:06 ` [ruby-core:37247] " Adam Prescott
2011-06-17 16:12 ` [ruby-core:37203] " Lazaridis Ilias
2011-06-25 11:10 ` [ruby-core:37347] " Lazaridis Ilias
2011-06-26 2:01 ` [ruby-core:37357] " Lazaridis Ilias
2011-06-26 2:01 ` [ruby-core:37358] " Lazaridis Ilias
2011-06-26 2:39 ` [ruby-core:37359] [Ruby 1.9 - Bug #4893][Assigned] " Shyouhei Urabe
2011-06-26 3:43 ` [ruby-core:37360] [Ruby 1.9 - Bug #4893] " John Higgins
2011-06-26 3:56 ` [ruby-core:37361] " John Higgins
2011-06-26 9:36 ` [ruby-core:37470] " Lazaridis Ilias
2011-06-26 11:06 ` [ruby-core:37518] " Lazaridis Ilias
2011-06-27 9:47 ` [ruby-core:37570] " Lazaridis Ilias
2011-06-27 10:12 ` [ruby-core:37571] " Shyouhei Urabe
2011-06-28 11:49 ` [ruby-core:37629] " Lazaridis Ilias
2011-06-29 0:31 ` [ruby-core:37648] " Shyouhei Urabe
2011-06-30 12:00 ` [ruby-core:37686] " Lazaridis Ilias
2011-06-30 17:13 ` [ruby-core:37692] [Ruby 1.9 - Bug #4893][Rejected] " Yukihiro Matsumoto
2011-07-01 5:12 ` [ruby-core:37712] [Ruby 1.9 - Bug #4893] " Lazaridis Ilias
2011-07-01 13:59 ` [ruby-core:37715] " Yukihiro Matsumoto
2011-07-02 9:22 ` [ruby-core:37733] " Lazaridis Ilias
2011-07-02 16:35 ` [ruby-core:37745] " Lazaridis Ilias
2011-07-04 12:02 ` [ruby-core:37768] " Lazaridis Ilias
2011-07-04 12:11 ` [ruby-core:37769] " Lazaridis Ilias
2011-07-04 15:28 ` [ruby-core:37772] " Lazaridis Ilias
2011-07-04 15:44 ` [ruby-core:37775] " Yukihiro Matsumoto
2011-07-04 17:07 ` [ruby-core:37784] " Lazaridis Ilias
2011-07-04 17:45 ` [ruby-core:37787] " Yukihiro Matsumoto
2011-07-05 13:46 ` [ruby-core:37797] " Lazaridis Ilias
2011-07-05 14:13 ` [ruby-core:37798] " Nikolai Weibull
2011-07-06 8:18 ` [ruby-core:37823] " Yukihiro Matsumoto
2011-07-06 20:26 ` [ruby-core:37832] " Lazaridis Ilias
2011-07-06 22:51 ` [ruby-core:37836] " Yukihiro Matsumoto
2011-07-09 9:35 ` [ruby-core:37915] " Lazaridis Ilias
2011-07-12 21:10 ` [ruby-core:38031] [Ruby 1.9 - Feature " Lazaridis Ilias
2011-07-12 23:18 ` [ruby-core:38032] " Lazaridis Ilias
2011-07-13 17:40 ` [ruby-core:38058] " Lazaridis Ilias
2011-07-13 18:43 ` [ruby-core:38060] " Magnus Holm
2011-07-13 18:37 ` [ruby-core:38059] " John Higgins
2011-07-17 0:10 ` [ruby-core:38114] " Lazaridis Ilias
2011-07-17 0:17 ` [ruby-core:38115] " Lazaridis Ilias
2011-07-17 2:56 ` [ruby-core:38122] " Lazaridis Ilias
2011-07-17 3:01 ` [ruby-core:38123] " Lazaridis Ilias
2011-07-17 18:06 ` [ruby-core:38146] " Lazaridis Ilias
2011-07-17 18:20 ` [ruby-core:38147] " Lazaridis Ilias
2011-07-21 5:27 ` [ruby-core:38302] " Lazaridis Ilias
2011-07-24 5:13 ` [ruby-core:38445] " Lazaridis Ilias
2011-07-24 13:23 ` [ruby-core:38450] [Ruby 1.9 - Feature #4893][Rejected] " Nobuyoshi Nakada
2011-07-24 14:55 ` [ruby-core:38457] [Ruby 1.9 - Feature #4893] " Lazaridis Ilias
2011-08-01 17:06 ` [ruby-core:38655] " Lazaridis Ilias
2011-09-21 7:11 ` [ruby-core:39653] " Lazaridis Ilias
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-18024.20110617040030@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).