[#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:25099] Re: Proposal: Simpler block format

From: Caleb Clausen <caleb@...>
Date: 2009-08-24 17:28:40 UTC
List: ruby-core #25099
Yehuda Katz wrote:
> On Sun, Aug 23, 2009 at 2:00 PM, Caleb Clausen <caleb@inforadical.net 
> <mailto:caleb@inforadical.net>> wrote:
>     But I'd like to see a more explicit description of how this would
>     work, if I am to implement it. Making reference to an existing
>     parser implementation is unhelpful for me, especially as I am not
>     familiar with the internals of that implementation. Things that
>     cause parse errors for MRI may not for redparse; redparse is
>     generally looser and more tolerant than MRI parse.y. In other words,
>     what would the appropriate section of a ruby standard read when
>     describing this feature?
> 
> 
> Understood -- but you do have the implementation to refer to. I agree 
> that in order for this to be accepted, we would need to provide new 
> RubySpecs to specify the behavior. I believe ujihisa is working on that.

A spec is nice and all, but I guess what I'm really looking for is a 
description in english, not in code, of how this new syntax behaves. I 
think it is important to have this kind of description in order to think 
about it properly. I haven't been able to persuade you to come up with 
such a thing, so maybe I'll take a shot at it:

A proc literal can be written as an expression enclosed in curly braces 
({}). Since blocks and hash literals can also be enclosed in curlys, 
there are some rules for distinguishing proc literals from those other 
cases:

1) If the { immediately follows an identifier, method name, or method 
argument list enclosed in parens, then it is a block.

2) If the { is followed by a parameter list enclosed by goalposts (||), 
then it is a proc literal.

3) If the {...} contains a pair of expressions, separated by =>, then it 
is a hash literal. (Note that => does not create an expression; it isn't 
valid on it's own but only inside a larger context.)

4) If the {...} contains a new-style hash initialization pair, in the 
form identifier: expression, then it is a hash literal. (Again, the : 
does not create an expression.)

5) If the {...} contains a list of such => or : pairs, separated by 
commas, then it is a hash literal.

6) An empty pair of curlys is always considered an (empty) hash literal.

7) Otherwise, {...} is a proc literal.

8) Note that in this case:
   { p q => r }
the => is not available to the {...}, to convert it to a hash literal, 
because the => has already been "eaten" by p's method parameter list. On 
the other hand, in these cases:
   { p {} => r }
   { p () => r }
the => does get used as part of the hash literal, since p's parameter 
list ends before the =>. (This is all consonant with existing rules 
about how parens following a method name get parsed. So, 8) shouldn't be 
confusing to parsers, but is potentially to humans.)


I agree with Matz that confusing the humans is a bad thing; to that end, 
perhaps this new syntax should be modified slightly so that
   { p q => r }
remains a syntax error. Users should add parentheses to disambiguate 
that into either
   { p( q => r ) }
or
   { p(q) => r }

So humans can always employ the rule that an => inside curlys creates a 
hash.

In This Thread