ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:69012] [Ruby trunk - Feature #11105] [Open] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
@ 2015-04-29  0:32 ` shugo
  2015-04-29  1:19   ` [ruby-core:69013] " Matthew Kerwin
                     ` (2 more replies)
  2015-04-29 13:06 ` [ruby-core:69021] [Ruby trunk - Feature #11105] " shugo
                   ` (13 subsequent siblings)
  14 siblings, 3 replies; 22+ messages in thread
From: shugo @ 2015-04-29  0:32 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been reported by Shugo Maeda.

----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105

* Author: Shugo Maeda
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69013] Re: [Ruby trunk - Feature #11105] [Open] ES6-like hash literals
  2015-04-29  0:32 ` [ruby-core:69012] [Ruby trunk - Feature #11105] [Open] ES6-like hash literals shugo
@ 2015-04-29  1:19   ` Matthew Kerwin
  2015-04-29  5:02   ` [ruby-core:69014] Problem with redmine (was: Re: [Ruby trunk - Feature #11105] [Open] ES6-like hash literals) "Martin J. Dürst"
  2015-04-29  6:56   ` [ruby-core:69015] Re: [Ruby trunk - Feature #11105] [Open] ES6-like hash literals Vít Ondruch
  2 siblings, 0 replies; 22+ messages in thread
From: Matthew Kerwin @ 2015-04-29  1:19 UTC (permalink / raw
  To: Ruby developers

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

​Shugo Maeda wrote:
> Why not support ECMAScript6-like hash literals?
>

Does it make code easier to read, or just easier to write? Personally I
find it a bit confusing/obfuscated.​

-- 
  Matthew Kerwin
  http://matthew.kerwin.net.au/

[-- Attachment #2: Type: text/html, Size: 1007 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69014] Problem with redmine (was: Re: [Ruby trunk - Feature #11105] [Open] ES6-like hash literals)
  2015-04-29  0:32 ` [ruby-core:69012] [Ruby trunk - Feature #11105] [Open] ES6-like hash literals shugo
  2015-04-29  1:19   ` [ruby-core:69013] " Matthew Kerwin
@ 2015-04-29  5:02   ` "Martin J. Dürst"
  2015-04-29 12:38     ` [ruby-core:69019] " SHIBATA Hiroshi
  2015-04-29  6:56   ` [ruby-core:69015] Re: [Ruby trunk - Feature #11105] [Open] ES6-like hash literals Vít Ondruch
  2 siblings, 1 reply; 22+ messages in thread
From: "Martin J. Dürst" @ 2015-04-29  5:02 UTC (permalink / raw
  To: Ruby developers

I tried to reply to Shugo on bugs.ruby-lang.org. However, I got the 
following validation message:

"% Done is not included in the list"

I do not know why I would have to indicate "% Done" on a feature that we 
only just started discussing. I also don't know where/how I would be 
indicating this (I could easily set the percentage to 0 if I knew where 
to do that).

Regards,    Martin.

On 2015/04/29 09:32, shugo@ruby-lang.org wrote:
> Issue #11105 has been reported by Shugo Maeda.
>
> ----------------------------------------
> Feature #11105: ES6-like hash literals
> https://bugs.ruby-lang.org/issues/11105
>
> * Author: Shugo Maeda
> * Status: Open
> * Priority: Normal
> * Assignee:
> ----------------------------------------
> Why not support ECMAScript6-like hash literals?
>
> For example,
>
>      {x, y}
>
> is equivalent to:
>
>      {x: x, y: y}
>
> For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:
>
>      a = 1
>      B = 2
>      $c = 3
>      @d = 4
>      @@e = 5
>      p({a, B, $c, @d, @@e, f: 6})
>      #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}
>
>
> ---Files--------------------------------
> 0001-support-ES6-like-hash-literals.patch (3.88 KB)
>
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69015] Re: [Ruby trunk - Feature #11105] [Open] ES6-like hash literals
  2015-04-29  0:32 ` [ruby-core:69012] [Ruby trunk - Feature #11105] [Open] ES6-like hash literals shugo
  2015-04-29  1:19   ` [ruby-core:69013] " Matthew Kerwin
  2015-04-29  5:02   ` [ruby-core:69014] Problem with redmine (was: Re: [Ruby trunk - Feature #11105] [Open] ES6-like hash literals) "Martin J. Dürst"
@ 2015-04-29  6:56   ` Vít Ondruch
  2 siblings, 0 replies; 22+ messages in thread
From: Vít Ondruch @ 2015-04-29  6:56 UTC (permalink / raw
  To: ruby-core

I really miss the times where hash rockets, e.g. `{:x => x, :y => y}`,
was the only option. I find `{x: x, y: y}` less readable and `{x, y}` is
totally unreadable IMO.


Vít


P.S. And yes, Redmine is broken :/


Dne 29.4.2015 v 02:32 shugo@ruby-lang.org napsal(a):
> Issue #11105 has been reported by Shugo Maeda.
>
> ----------------------------------------
> Feature #11105: ES6-like hash literals
> https://bugs.ruby-lang.org/issues/11105
>
> * Author: Shugo Maeda
> * Status: Open
> * Priority: Normal
> * Assignee: 
> ----------------------------------------
> Why not support ECMAScript6-like hash literals?
>
> For example,
>
>     {x, y}
>
> is equivalent to:
>
>     {x: x, y: y}
>
> For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:
>
>     a = 1
>     B = 2
>     $c = 3
>     @d = 4
>     @@e = 5
>     p({a, B, $c, @d, @@e, f: 6})
>     #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}
>
>
> ---Files--------------------------------
> 0001-support-ES6-like-hash-literals.patch (3.88 KB)
>
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69019] Re: Problem with redmine (was: Re: [Ruby trunk - Feature #11105] [Open] ES6-like hash literals)
  2015-04-29  5:02   ` [ruby-core:69014] Problem with redmine (was: Re: [Ruby trunk - Feature #11105] [Open] ES6-like hash literals) "Martin J. Dürst"
@ 2015-04-29 12:38     ` SHIBATA Hiroshi
  0 siblings, 0 replies; 22+ messages in thread
From: SHIBATA Hiroshi @ 2015-04-29 12:38 UTC (permalink / raw
  To: Ruby developers

Hi Martin.

I fixed this issue. it is caused by latest version of redmine.
Please try to report again.

Thanks.

On Wed, Apr 29, 2015 at 2:02 PM, "Martin J. Dürst"
<duerst@it.aoyama.ac.jp> wrote:
> I tried to reply to Shugo on bugs.ruby-lang.org. However, I got the
> following validation message:
>
> "% Done is not included in the list"
>
> I do not know why I would have to indicate "% Done" on a feature that we
> only just started discussing. I also don't know where/how I would be
> indicating this (I could easily set the percentage to 0 if I knew where to
> do that).
>
> Regards,    Martin.
>
> On 2015/04/29 09:32, shugo@ruby-lang.org wrote:
>>
>> Issue #11105 has been reported by Shugo Maeda.
>>
>> ----------------------------------------
>> Feature #11105: ES6-like hash literals
>> https://bugs.ruby-lang.org/issues/11105
>>
>> * Author: Shugo Maeda
>> * Status: Open
>> * Priority: Normal
>> * Assignee:
>> ----------------------------------------
>> Why not support ECMAScript6-like hash literals?
>>
>> For example,
>>
>>      {x, y}
>>
>> is equivalent to:
>>
>>      {x: x, y: y}
>>
>> For convenience, the prefix of global, instance, and class variables
>> should be removed from the key name as follows:
>>
>>      a = 1
>>      B = 2
>>      $c = 3
>>      @d = 4
>>      @@e = 5
>>      p({a, B, $c, @d, @@e, f: 6})
>>      #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}
>>
>>
>> ---Files--------------------------------
>> 0001-support-ES6-like-hash-literals.patch (3.88 KB)
>>
>>
>



-- 
SHIBATA Hiroshi shibata.hiroshi@gmail.com
http://www.hsbt.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69021] [Ruby trunk - Feature #11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
  2015-04-29  0:32 ` [ruby-core:69012] [Ruby trunk - Feature #11105] [Open] ES6-like hash literals shugo
@ 2015-04-29 13:06 ` shugo
  2015-04-29 17:34   ` [ruby-core:69023] " Besnik Ruka
  2015-04-29 21:32 ` [ruby-core:69024] " rr.rosas
                   ` (12 subsequent siblings)
  14 siblings, 1 reply; 22+ messages in thread
From: shugo @ 2015-04-29 13:06 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by Shugo Maeda.


2015-04-29 10:19 GMT+09:00 Matthew Kerwin <matthew@kerwin.net.au>:
> Shugo Maeda wrote:
>> Why not support ECMAScript6-like hash literals?
>> 
>
> Does it make code easier to read, or just easier to write? Personally I find
> it a bit confusing/obfuscated.

The proposed syntax contributes to readability because it reduces redundancy and
tells us that a key has the same name as the corresponding variable.

For example, it is obvious that only name has a different name from
the corresponding variable in the following code:

    h = {
      name: username,
      password,
      e_mail
    }


----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-52277

* Author: Shugo Maeda
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69023] Re: [Ruby trunk - Feature #11105] ES6-like hash literals
  2015-04-29 13:06 ` [ruby-core:69021] [Ruby trunk - Feature #11105] " shugo
@ 2015-04-29 17:34   ` Besnik Ruka
  0 siblings, 0 replies; 22+ messages in thread
From: Besnik Ruka @ 2015-04-29 17:34 UTC (permalink / raw
  To: Ruby developers

[-- Attachment #1: Type: text/plain, Size: 2502 bytes --]

It does look easier to read but feels like it would be harder to write and
debug.

What if you're typing in a hurry, or doing a lot of copy/paste and somehow
you accidentally omit a key? Currently the interpreter would raise a syntax
error immediately, but with this you would get cryptic logic bugs where the
size of the hash is correct, but the key you want is missing.

Also this pretty much means you can't have an expression as the value i.e.
  h = {
    name.upcase,
    email
  }

Another issue might be that this basically ties your hash to the naming of
your variables:

  def sanitize_name(name, email)
    name = name.upcase
    return { name, email }
  end

Which looks fine, but if later on i decide to go back and rename my local
variable, I'd have to go find everywhere i've used that hash and make sure
the key is changed properly. Not sure I want that kind of coupling.

None of these are deal breakers, but things to consider.

On Wed, Apr 29, 2015 at 9:06 AM, <shugo@ruby-lang.org> wrote:

> Issue #11105 has been updated by Shugo Maeda.
>
>
> 2015-04-29 10:19 GMT+09:00 Matthew Kerwin <matthew@kerwin.net.au>:
> > Shugo Maeda wrote:
> >> Why not support ECMAScript6-like hash literals?
> >>
> >
> > Does it make code easier to read, or just easier to write? Personally I
> find
> > it a bit confusing/obfuscated.
>
> The proposed syntax contributes to readability because it reduces
> redundancy and
> tells us that a key has the same name as the corresponding variable.
>
> For example, it is obvious that only name has a different name from
> the corresponding variable in the following code:
>
>     h = {
>       name: username,
>       password,
>       e_mail
>     }
>
>
> ----------------------------------------
> Feature #11105: ES6-like hash literals
> https://bugs.ruby-lang.org/issues/11105#change-52277
>
> * Author: Shugo Maeda
> * Status: Open
> * Priority: Normal
> * Assignee:
> ----------------------------------------
> Why not support ECMAScript6-like hash literals?
>
> For example,
>
>     {x, y}
>
> is equivalent to:
>
>     {x: x, y: y}
>
> For convenience, the prefix of global, instance, and class variables
> should be removed from the key name as follows:
>
>     a = 1
>     B = 2
>     $c = 3
>     @d = 4
>     @@e = 5
>     p({a, B, $c, @d, @@e, f: 6})
>     #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}
>
>
> ---Files--------------------------------
> 0001-support-ES6-like-hash-literals.patch (3.88 KB)
>
>
> --
> https://bugs.ruby-lang.org/
>

[-- Attachment #2: Type: text/html, Size: 3666 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69024] [Ruby trunk - Feature #11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
  2015-04-29  0:32 ` [ruby-core:69012] [Ruby trunk - Feature #11105] [Open] ES6-like hash literals shugo
  2015-04-29 13:06 ` [ruby-core:69021] [Ruby trunk - Feature #11105] " shugo
@ 2015-04-29 21:32 ` rr.rosas
  2015-04-30  1:36 ` [ruby-core:69025] " mame
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 22+ messages in thread
From: rr.rosas @ 2015-04-29 21:32 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by Rodrigo Rosenfeld Rosas.


I use that a lot with CoffeeScript and would love to be able to do the same with Ruby. +1

----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-52280

* Author: Shugo Maeda
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69025] [Ruby trunk - Feature #11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2015-04-29 21:32 ` [ruby-core:69024] " rr.rosas
@ 2015-04-30  1:36 ` mame
  2015-04-30  2:36 ` [ruby-core:69026] " matz
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 22+ messages in thread
From: mame @ 2015-04-30  1:36 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by Yusuke Endoh.


-1.

{x, y} is a conventional notation of a mathematical set.
When I read it, I expect it to be equivalent to { x => true, y => true }.

-- 
Yusuke Endoh <mame@ruby-lang.org>

----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-52281

* Author: Shugo Maeda
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69026] [Ruby trunk - Feature #11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2015-04-30  1:36 ` [ruby-core:69025] " mame
@ 2015-04-30  2:36 ` matz
  2015-04-30  2:38   ` [ruby-core:69027] " Alfredo Bravo Cuero
  2015-04-30  2:50 ` [ruby-core:69028] " shugo
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 22+ messages in thread
From: matz @ 2015-04-30  2:36 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by Yukihiro Matsumoto.


Question:

What if we have variables with same name and different prefixes? e.g.

a = 1
@a = 2
$a = 3

Matz.

----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-52282

* Author: Shugo Maeda
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69027] Re: [Ruby trunk - Feature #11105] ES6-like hash literals
  2015-04-30  2:36 ` [ruby-core:69026] " matz
@ 2015-04-30  2:38   ` Alfredo Bravo Cuero
  0 siblings, 0 replies; 22+ messages in thread
From: Alfredo Bravo Cuero @ 2015-04-30  2:38 UTC (permalink / raw
  To: Ruby developers

[-- Attachment #1: Type: text/plain, Size: 1299 bytes --]

Hola matz


Alfredo Bravo Cuero (@abracu)
Open Source culture advocate and Ruby on Rails Developer 
| Skype: yo@alfredobravocuero.co | Cel +573192837240

Enviado desde mi iPad

> El 29/04/2015, a las 9:36 p.m., matz@ruby-lang.org escribió:
> 
> Issue #11105 has been updated by Yukihiro Matsumoto.
> 
> 
> Question:
> 
> What if we have variables with same name and different prefixes? e.g.
> 
> a = 1
> @a = 2
> $a = 3
> 
> Matz.
> 
> ----------------------------------------
> Feature #11105: ES6-like hash literals
> https://bugs.ruby-lang.org/issues/11105#change-52282
> 
> * Author: Shugo Maeda
> * Status: Open
> * Priority: Normal
> * Assignee: 
> ----------------------------------------
> Why not support ECMAScript6-like hash literals?
> 
> For example,
> 
>    {x, y}
> 
> is equivalent to:
> 
>    {x: x, y: y}
> 
> For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:
> 
>    a = 1
>    B = 2
>    $c = 3
>    @d = 4
>    @@e = 5
>    p({a, B, $c, @d, @@e, f: 6})
>    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}
> 
> 
> ---Files--------------------------------
> 0001-support-ES6-like-hash-literals.patch (3.88 KB)
> 
> 
> -- 
> https://bugs.ruby-lang.org/

[-- Attachment #2: Type: text/html, Size: 2757 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69028] [Ruby trunk - Feature #11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2015-04-30  2:36 ` [ruby-core:69026] " matz
@ 2015-04-30  2:50 ` shugo
  2015-04-30  2:55 ` [ruby-core:69029] " shugo
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 22+ messages in thread
From: shugo @ 2015-04-30  2:50 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by Shugo Maeda.


Yukihiro Matsumoto wrote:
> What if we have variables with same name and different prefixes? e.g.
> 
> a = 1
> @a = 2
> $a = 3

The last one is used with warnings:

```
lexington:ruby$ cat x.rb
a = 1
@a = 2
$a = 3
p({a, @a, $a})
lexington:ruby$ ./ruby x.rb
x.rb:4: warning: duplicated key at line 4 ignored: :a
x.rb:4: warning: duplicated key at line 4 ignored: :a
{:a=>3}
```


----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-52284

* Author: Shugo Maeda
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69029] [Ruby trunk - Feature #11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2015-04-30  2:50 ` [ruby-core:69028] " shugo
@ 2015-04-30  2:55 ` shugo
  2015-04-30 13:32   ` [ruby-core:69032] " Carlos Agarie
  2015-05-05 12:36 ` [ruby-core:69078] " rr.rosas
                   ` (7 subsequent siblings)
  14 siblings, 1 reply; 22+ messages in thread
From: shugo @ 2015-04-30  2:55 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by Shugo Maeda.


Yusuke Endoh wrote:
> {x, y} is a conventional notation of a mathematical set.
> When I read it, I expect it to be equivalent to { x => true, y => true }.

{x, y} looks like a set of variable bindings, so it's reasonable that each key is a variable name and each value is its value.


----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-52285

* Author: Shugo Maeda
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69032] Re: [Ruby trunk - Feature #11105] ES6-like hash literals
  2015-04-30  2:55 ` [ruby-core:69029] " shugo
@ 2015-04-30 13:32   ` Carlos Agarie
  0 siblings, 0 replies; 22+ messages in thread
From: Carlos Agarie @ 2015-04-30 13:32 UTC (permalink / raw
  To: Ruby developers

As Yusuke Endoh said, I'd expect this notation to create a Set, not a Hash...

-----
Carlos Agarie
+55 11 97320-3878 | @carlos_agarie


2015-04-29 23:55 GMT-03:00  <shugo@ruby-lang.org>:
> Issue #11105 has been updated by Shugo Maeda.
>
>
> Yusuke Endoh wrote:
>> {x, y} is a conventional notation of a mathematical set.
>> When I read it, I expect it to be equivalent to { x => true, y => true }.
>
> {x, y} looks like a set of variable bindings, so it's reasonable that each key is a variable name and each value is its value.
>
>
> ----------------------------------------
> Feature #11105: ES6-like hash literals
> https://bugs.ruby-lang.org/issues/11105#change-52285
>
> * Author: Shugo Maeda
> * Status: Open
> * Priority: Normal
> * Assignee:
> ----------------------------------------
> Why not support ECMAScript6-like hash literals?
>
> For example,
>
>     {x, y}
>
> is equivalent to:
>
>     {x: x, y: y}
>
> For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:
>
>     a = 1
>     B = 2
>     $c = 3
>     @d = 4
>     @@e = 5
>     p({a, B, $c, @d, @@e, f: 6})
>     #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}
>
>
> ---Files--------------------------------
> 0001-support-ES6-like-hash-literals.patch (3.88 KB)
>
>
> --
> https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69078] [Ruby trunk - Feature #11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2015-04-30  2:55 ` [ruby-core:69029] " shugo
@ 2015-05-05 12:36 ` rr.rosas
  2015-05-08  7:02 ` [ruby-core:69106] " nobu
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 22+ messages in thread
From: rr.rosas @ 2015-05-05 12:36 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by Rodrigo Rosenfeld Rosas.


Yukihiro Matsumoto wrote:
> Question:
> 
> What if we have variables with same name and different prefixes? e.g.
> 
> a = 1
> @a = 2
> $a = 3

CoffeeScript would compile to this:

~~~
@a=1; a=2; {@a, a} => {a: this.a, a: a}
~~~

If the same happens in Ruby, this is what I get in IRB:

~~~
> {a: 1, a: 2}
(irb):2: warning: duplicated key at line 2 ignored: :a
=> {:a=>2}
~~~

Sounds good to me.

----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-52325

* Author: Shugo Maeda
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69106] [Ruby trunk - Feature #11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2015-05-05 12:36 ` [ruby-core:69078] " rr.rosas
@ 2015-05-08  7:02 ` nobu
  2015-05-14  9:15 ` [ruby-core:69190] " shugo
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 22+ messages in thread
From: nobu @ 2015-05-08  7:02 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by Nobuyoshi Nakada.


Shugo Maeda wrote:
> ```
> lexington:ruby$ cat x.rb
> a = 1
> @a = 2
> $a = 3
> p({a, @a, $a})
> lexington:ruby$ ./ruby x.rb
> x.rb:4: warning: duplicated key at line 4 ignored: :a
> x.rb:4: warning: duplicated key at line 4 ignored: :a
> {:a=>3}
> ```

Why they make the same symbol?
`a`, `@a` and `$a` are irrelevant, separate variables.
I'd expect `{:a=>1, :@a=>2, :$a=>3}` without any warnings.

----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-52351

* Author: Shugo Maeda
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69190] [Ruby trunk - Feature #11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2015-05-08  7:02 ` [ruby-core:69106] " nobu
@ 2015-05-14  9:15 ` shugo
  2015-05-14  9:30 ` [ruby-core:69191] [Ruby trunk - Feature #11105] [Rejected] " matz
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 22+ messages in thread
From: shugo @ 2015-05-14  9:15 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by Shugo Maeda.


Nobuyoshi Nakada wrote:
> > lexington:ruby$ ./ruby x.rb
> > x.rb:4: warning: duplicated key at line 4 ignored: :a
> > x.rb:4: warning: duplicated key at line 4 ignored: :a
> > {:a=>3}
> > ```
> 
> Why they make the same symbol?
> `a`, `@a` and `$a` are irrelevant, separate variables.
> I'd expect `{:a=>1, :@a=>2, :$a=>3}` without any warnings.

Because I don't come up with any use case of such ugly key names.
I believe code like {a, @a} should not be used in real world applications.


----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-52447

* Author: Shugo Maeda
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:69191] [Ruby trunk - Feature #11105] [Rejected] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2015-05-14  9:15 ` [ruby-core:69190] " shugo
@ 2015-05-14  9:30 ` matz
  2017-06-19 22:32 ` [ruby-core:81727] [Ruby trunk Feature#11105] " tleish
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 22+ messages in thread
From: matz @ 2015-05-14  9:30 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by Yukihiro Matsumoto.

Status changed from Open to Rejected

I am not positive about this syntax mostly because it appears to be set syntax, or old style hash in 1.8.
Once ES6 syntax become more popular, there will be chance for this change in the future.

Matz.


----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-52448

* Author: Shugo Maeda
* Status: Rejected
* Priority: Normal
* Assignee: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:81727] [Ruby trunk Feature#11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2015-05-14  9:30 ` [ruby-core:69191] [Ruby trunk - Feature #11105] [Rejected] " matz
@ 2017-06-19 22:32 ` tleish
  2017-08-24  3:55 ` [ruby-core:82458] " knu
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 22+ messages in thread
From: tleish @ 2017-06-19 22:32 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by tleish (Tony Fenleish).


+1

While it might be odd or new for some, using this in ES6 has been very nice.  I am often wishing this was supported in Ruby.  The cognitive load is so much nicer and less redundant.

I wish it could be reconsidered.

----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-65427

* Author: shugo (Shugo Maeda)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:82458] [Ruby trunk Feature#11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2017-06-19 22:32 ` [ruby-core:81727] [Ruby trunk Feature#11105] " tleish
@ 2017-08-24  3:55 ` knu
  2017-08-24 22:26 ` [ruby-core:82460] " xkernigh
  2017-08-25  1:55 ` [ruby-core:82466] " nobu
  14 siblings, 0 replies; 22+ messages in thread
From: knu @ 2017-08-24  3:55 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by knu (Akinori MUSHA).


This syntax is now widely known and popular in the JavaScript/ES world.  It is frequently used in everyday code and we've grown used to it.

----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-66268

* Author: shugo (Shugo Maeda)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:82460] [Ruby trunk Feature#11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (12 preceding siblings ...)
  2017-08-24  3:55 ` [ruby-core:82458] " knu
@ 2017-08-24 22:26 ` xkernigh
  2017-08-25  1:55 ` [ruby-core:82466] " nobu
  14 siblings, 0 replies; 22+ messages in thread
From: xkernigh @ 2017-08-24 22:26 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by kernigh (George Koehler).


This ES6 syntax for hash literals looks strange to me. I have never seen it before today, but I have not written JavaScript for a few years, and I am not using Ruby for web development.

Two things puzzle me:

1. What is the key in `{@a}`? I want `:@a` as the key, others want `:a`. I don't expect Ruby to change `a` into `@a`. For example, `object.instance_variable_get :a` raises NameError, but `object.instance_variable_get :@a` works.
2. Should `{print}` call the method `print` if there's no local variable? That's what `{print: print}` would do.

----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-66270

* Author: shugo (Shugo Maeda)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ruby-core:82466] [Ruby trunk Feature#11105] ES6-like hash literals
       [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
                   ` (13 preceding siblings ...)
  2017-08-24 22:26 ` [ruby-core:82460] " xkernigh
@ 2017-08-25  1:55 ` nobu
  14 siblings, 0 replies; 22+ messages in thread
From: nobu @ 2017-08-25  1:55 UTC (permalink / raw
  To: ruby-core

Issue #11105 has been updated by nobu (Nobuyoshi Nakada).


It makes many conflicts with the current syntax.
I don't think it is easy to resolve.

----------------------------------------
Feature #11105: ES6-like hash literals
https://bugs.ruby-lang.org/issues/11105#change-66276

* Author: shugo (Shugo Maeda)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Why not support ECMAScript6-like hash literals?

For example,

    {x, y}

is equivalent to:

    {x: x, y: y}

For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows:

    a = 1
    B = 2
    $c = 3
    @d = 4
    @@e = 5
    p({a, B, $c, @d, @@e, f: 6})
    #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6}


---Files--------------------------------
0001-support-ES6-like-hash-literals.patch (3.88 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-08-25  1:56 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-11105.20150429003239@ruby-lang.org>
2015-04-29  0:32 ` [ruby-core:69012] [Ruby trunk - Feature #11105] [Open] ES6-like hash literals shugo
2015-04-29  1:19   ` [ruby-core:69013] " Matthew Kerwin
2015-04-29  5:02   ` [ruby-core:69014] Problem with redmine (was: Re: [Ruby trunk - Feature #11105] [Open] ES6-like hash literals) "Martin J. Dürst"
2015-04-29 12:38     ` [ruby-core:69019] " SHIBATA Hiroshi
2015-04-29  6:56   ` [ruby-core:69015] Re: [Ruby trunk - Feature #11105] [Open] ES6-like hash literals Vít Ondruch
2015-04-29 13:06 ` [ruby-core:69021] [Ruby trunk - Feature #11105] " shugo
2015-04-29 17:34   ` [ruby-core:69023] " Besnik Ruka
2015-04-29 21:32 ` [ruby-core:69024] " rr.rosas
2015-04-30  1:36 ` [ruby-core:69025] " mame
2015-04-30  2:36 ` [ruby-core:69026] " matz
2015-04-30  2:38   ` [ruby-core:69027] " Alfredo Bravo Cuero
2015-04-30  2:50 ` [ruby-core:69028] " shugo
2015-04-30  2:55 ` [ruby-core:69029] " shugo
2015-04-30 13:32   ` [ruby-core:69032] " Carlos Agarie
2015-05-05 12:36 ` [ruby-core:69078] " rr.rosas
2015-05-08  7:02 ` [ruby-core:69106] " nobu
2015-05-14  9:15 ` [ruby-core:69190] " shugo
2015-05-14  9:30 ` [ruby-core:69191] [Ruby trunk - Feature #11105] [Rejected] " matz
2017-06-19 22:32 ` [ruby-core:81727] [Ruby trunk Feature#11105] " tleish
2017-08-24  3:55 ` [ruby-core:82458] " knu
2017-08-24 22:26 ` [ruby-core:82460] " xkernigh
2017-08-25  1:55 ` [ruby-core:82466] " nobu

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