[#24648] [Bug #1852] Enumerable's #hash Raises ArgumentError When Recursive Values are Present — Run Paint Run Run <redmine@...>

Bug #1852: Enumerable's #hash Raises ArgumentError When Recursive Values are Present

20 messages 2009/08/01
[#24649] Re: [Bug #1852] Enumerable's #hash Raises ArgumentError When Recursive Values are Present — Tanaka Akira <akr@...> 2009/08/01

In article <4a73e51b5a4f9_138119f2a982704e@redmine.ruby-lang.org>,

[#24652] Re: [Bug #1852] Enumerable's #hash Raises ArgumentError When Recursive Values are Present — Run Paint Run Run <runrun@...> 2009/08/01

> Is it valuable to implement such function?

[#24682] Re: [Bug #1852] Enumerable's #hash Raises ArgumentError When Recursive Values are Present — Tanaka Akira <akr@...> 2009/08/02

In article <67e307490908010125r6fa76654pa8e2224f714588fc@mail.gmail.com>,

[#24673] [Feature #1857] install *.h and *.inc — Roger Pack <redmine@...>

Feature #1857: install *.h and *.inc

21 messages 2009/08/01

[#24732] [Bug #1873] MatchData#[]: Omits All But Last Captures Corresponding to the Same Named Group — Run Paint Run Run <redmine@...>

Bug #1873: MatchData#[]: Omits All But Last Captures Corresponding to the Same Named Group

12 messages 2009/08/03

[#24775] [Feature #1889] Teach Onigurma Unicode 5.0 Character Properties — Run Paint Run Run <redmine@...>

Feature #1889: Teach Onigurma Unicode 5.0 Character Properties

30 messages 2009/08/05

[#24786] [Bug #1893] Recursive Enumerable#join is surprising — Jeremy Kemper <redmine@...>

Bug #1893: Recursive Enumerable#join is surprising

24 messages 2009/08/06
[#28422] [Bug #1893] Recursive Enumerable#join is surprising — Yusuke Endoh <redmine@...> 2010/03/02

Issue #1893 has been updated by Yusuke Endoh.

[#28438] Re: [Bug #1893] Recursive Enumerable#join is surprising — Yukihiro Matsumoto <matz@...> 2010/03/03

Hi,

[#24854] embedding ruby 1.9 frustration — Rolando Abarca <funkaster@...>

Hello,

12 messages 2009/08/10

[#24982] [Feature #1961] Kernel#__dir__ — Yutaka HARA <redmine@...>

Feature #1961: Kernel#__dir__

26 messages 2009/08/19
[#28898] [Feature #1961] Kernel#__dir__ — Roger Pack <redmine@...> 2010/03/23

Issue #1961 has been updated by Roger Pack.

[#28900] Re: [Feature #1961] Kernel#__dir__ — Kornelius Kalnbach <murphy@...> 2010/03/23

On 23.03.10 19:10, Roger Pack wrote:

[#25025] [Backport #1975] Backport Dir.mktmpdir — Kirk Haines <redmine@...>

Backport #1975: Backport Dir.mktmpdir

12 messages 2009/08/21

[#25041] Proposal: Simpler block format — Yehuda Katz <wycats@...>

I'd like to propose that we add the following syntax for procs in Ruby:

45 messages 2009/08/23
[#25046] Re: Proposal: Simpler block format — Caleb Clausen <caleb@...> 2009/08/23

Yehuda Katz wrote:

[#25049] Re: Proposal: Simpler block format — Yehuda Katz <wycats@...> 2009/08/23

On Sat, Aug 22, 2009 at 7:38 PM, Caleb Clausen <caleb@inforadical.net>wrote:

[#25058] Re: Proposal: Simpler block format — Yukihiro Matsumoto <matz@...> 2009/08/23

Hi,

[#25059] Re: Proposal: Simpler block format — Yehuda Katz <wycats@...> 2009/08/23

On Sun, Aug 23, 2009 at 3:33 PM, Yukihiro Matsumoto <matz@ruby-lang.org>wrote:

[#25063] Re: Proposal: Simpler block format — "David A. Black" <dblack@...> 2009/08/23

Hi --

[#25068] Re: Proposal: Simpler block format — brian ford <brixen@...> 2009/08/24

Hi,

[#25086] [Bug #1991] ruby should use twolevel namespace on OS X — Michal Suchanek <redmine@...>

Bug #1991: ruby should use twolevel namespace on OS X

12 messages 2009/08/24

[#25208] Module#prepend and Array#prepend — Yehuda Katz <wycats@...>

Matz,

23 messages 2009/08/30

[#25210] [Feature #2022] Patch for ruby-1.8.6 and openssl-1.0 — Jeroen van Meeuwen <redmine@...>

Feature #2022: Patch for ruby-1.8.6 and openssl-1.0

15 messages 2009/08/30

[#25220] [Bug #2026] String encodings are not supported by most of IO on Linux — Vit Ondruch <redmine@...>

Bug #2026: String encodings are not supported by most of IO on Linux

18 messages 2009/08/31

[ruby-core:25219] Re: Module#prepend and Array#prepend

From: Rick DeNatale <rick.denatale@...>
Date: 2009-08-31 13:45:07 UTC
List: ruby-core #25219
On Mon, Aug 31, 2009 at 8:39 AM, Yusuke ENDOH<mame@tsg.ne.jp> wrote:
> I cannot guess the problem you want to solve.  know this mail
> is just discussion log or reminder, but I'd like you to elaborate
> your proposal completely when sending to ruby-core.
>
> Why don't you define subclass explicitly?
>
> lass Person
> ef speak(words)
> uts words
> nd
> nd
> odule Exclaim
> ef speak(words)
> uper("#{ words }!")
> nd
> nd
> lass Exclaimer < Person
> nclude Exclaim
> nd
> xclaimer.new.speak("matz") #=> matz!

Perhaps I'm mistaken but I think that besides the 'syntax' difference,
Yehuda's intent was that something like this would work:


class Person
    def speak(str)
         str
    end
end

p = Person.new

p.speak("hello") #=> "hello"

module LoudSpeaker
   def speak(str)
         super(str.upcase)
   end
   end
end

class Person
    prepend Voice
end

p.speak("hello") #=> "HELLO"

If this is the intent, it's more than adjusting the ancestor chain of
the class when it prepends a module, but adjusting the ancestor chain
of any present and future instances of that class.

I think that this is the intent because of something Yehuda said in
the post which started this thread: "Effectively, prepend would
prepend a module to the class' ancestor chain. Implementation-wise, it
means that all methods on a class are put into an implicit module, or
an implicit subclass is created for each new class that can have
modules mixed into it (via prepend)."

Although hidden, or maybe transparent, might be a better word here than hidden.

I think there are several interesting discussion topics about this idea.

First, is it useful enough to carry it's weight.

Second, if it is what's the 'right' syntax.

Third, what's the impact on implementation and potential for edge cases.

I think that the Yehuda's implementation suggestions are that either:

   The existing hash in class objects which maps method selectors to
methods would actually be empty, or at least not consulted directly
during method lookup and the class would start out with klass pointing
to something akin to a module proxy, really a class proxy pointing to
the instance method hash of the class.  The prepend method would
insert a module proxy for the module being prepended at the head of
the chain started by the klass field of the class. The current include
method would search the klass chain for the special class proxy and
insert the module proxy just after that.

or

 A hidden subclass with no instance methods be created for each class
which could "have modules mixed into it (via prepend)" and  instances
of the class would actually be directly instances of this hidden class
instead of the class itself.  Prepend would insert a module proxy
between this hidden class and the actual class.  I think that this
would need to be the case for every class since I don't know how you
would predict if prepend would be sent to the class in future.

These two alternatives seem to me to be only subtly different, I
suspect that the first one is cleaner, but I don't know.

Some questions that occur to me:

1) Since prepend is really a variation on include, if you can prepend
a module to a class, why can't you prepend a module to a  module

2) Is there a similar variant for extend?

3) Which is related to the question of should you be able to prepend
to a singleton-class?

4) Are there edge-cases related to handing super?  Right now unless
it's changed (again) in Ruby 1.9, include takes pains not to have a
proxy to the same module show up twice in an ancestor chain because of
the way super method lookup works by searching first from the
beginning of self's klass chain for the current method, then searching
again for the next one, which can cause unexpected results if super is
used in a method invoked itself from super earlier in the chain.


-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

In This Thread