> Perhaps this is a plea better left for the Prototype-core list.

Like I said, I'm not a decision maker here.  But breaking contracts is
pretty well established as a Bad Idea.

-- T.J. ;-)

On Feb 3, 6:54 pm, Brad <bradavo...@gmail.com> wrote:
> TJ, thanks for correcting the docs. I hadn't noticed that error
> either.
>
> Are you suggesting that there no intersection of Prototype and Ruby
> communities? I only know of Prototype because of Ruby on Rails.
>
> Let's take Hash#reject() as an example. Let's say I'm moving server-
> side Ruby code to my Prototype-enhanced client-side.
>
> Ruby code:
> { "a" => 100, "b" => 200, "c" => 300 }.reject {|key, value| key ==
> "b" }
> => {"a"=>100, "c"=>300}
>
> Translated to Javascript:
> $H({ "a": 100, "b": 200, "c": 300 }).reject(function(i) { return i.key
> == "b" })
> => [["a", 100], ["c", 300]]
>
> Prototype returns an array? What good is an array if I started with a
> hash? It is intuitive that a reject() method returns a subset of the
> original data structure and not convert it to an entirely different
> one.
>
> Perhaps this is a plea better left for the Prototype-core list.
>
> On Feb 3, 6:18 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
>
> > Hi,
>
> > > Maybe filter should be an alias of findall for arrays, but shouldn't
> > > it really return a hash for hashes?
>
> > FWIW (and it ain't much, I'm not a decision maker on Prototype stuff),
> > in my opinion it would be an _extremely_ bad idea for Hash to break
> > the contract documented for Enumerable.
>
> > > ...in ruby, which Prototype is supposed to be modeled after.
>
> > Prototype has been split off from Ruby for a long time now.  I'd
> > venture to say that most people using Prototype do not use and may
> > well never have even seen Ruby.  PHP seems to be the server-side
> > language I see most in code snippets from people asking questions.
> > --
> > T.J. Crowder
> > tj / crowder software / com
> > Independent Software Engineer, consulting services available
>
> > On Feb 3, 2:04 pm, disccomp <discc...@gmail.com> wrote:
>
> > > Maybe filter should be an alias of findall for arrays, but shouldn't
> > > it really return a hash for hashes? Especially if thats its behavior
> > > in ruby, which Prototype is supposed to be modeled after.
>
> > > On Feb 3, 4:59 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
>
> > > > Hi Brad,
>
> > > > Sorry, I missed that Hash inherits from Enumerable (and I've filed a
> > > > doc bug on it[1] and will fix it -- the doc page for Hash doesn't
> > > > mention Enumerable).
>
> > > > So I think that's your answer:  Hash#filter is an alias for
> > > > Enumerable#findAll[2], which is documented as returning an array, not
> > > > a Hash, and so having it return a Hash would be breaking the contract.
>
> > > > [1]http://prototype.lighthouseapp.com/projects/8886-prototype/tickets/535
> > > > [2]http://prototypejs.org/api/enumerable/findall
>
> > > > Sorry again to have missed the Enumerable thing in the first place.
> > > > --
> > > > T.J. Crowder
> > > > tj / crowder software / com
> > > > Independent Software Engineer, consulting services available
>
> > > > On Feb 3, 12:25 am, Brad <bradavo...@gmail.com> wrote:
>
> > > > > It does. Hash still inherits from Enumerable, hence the usage of
> > > > > Hash#findAll().
>
> > > > > - Brad
>
> > > > > On Feb 2, 1:34 am, ColinFine <colin.f...@pace.com> wrote:
>
> > > > > > On Jan 31, 11:11 pm, Brad <bradavo...@gmail.com> wrote:
>
> > > > > > > Yup, found it -http://dev.rubyonrails.org/ticket/3592
>
> > > > > > > It is indeed a bug in Prototype that hasn't been addressed.
>
> > > > > > > - Brad
>
> > > > > > But it seems to me that it's gone away, because Hash no longer mixes
> > > > > > in Enumerable, does it?
>
> > > > > > Colin
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to