[#100309] How to use backport custom field — Jun Aruga <jaruga@...>
Please allow my ignorance.
9 messages
2020/10/06
[#100310] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
IkJhY2twb3J0IGN1c3RvbSBmaWVsZCIgaXMgb25seSBhdmFpbGFibGUgZm9yIHRpY2tldHMgd2hv
[#100311] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/06
On Tue, Oct 6, 2020 at 4:44 PM NARUSE, Yui <[email protected]> wrote:
[#100314] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
VGhhbmsgeW91IGZvciBjb25maXJtYXRpb24uCkkgY2hlY2tlZCBhZ2FpbiBhbmQgdG8gZWRpdCBi
[#100322] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Tue, Oct 6, 2020 at 7:25 PM NARUSE, Yui <[email protected]> wrote:
[#100326] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/07
SSBhZGRlZCB5b3UgdG8gIlJlcG9ydGVyIiByb2xlIGluIHRoZSBwcm9qZWN0CgoyMDIw5bm0MTDm
[#100327] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Wed, Oct 7, 2020 at 1:42 PM NARUSE, Yui <[email protected]> wrote:
[ruby-core:100635] [Ruby master Feature#17292] Hash Shorthand / Punning
From:
keystonelemur@...
Date:
2020-10-29 05:07:19 UTC
List:
ruby-core #100635
Issue #17292 has been reported by baweaver (Brandon Weaver).
----------------------------------------
Feature #17292: Hash Shorthand / Punning
https://bugs.ruby-lang.org/issues/17292
* Author: baweaver (Brandon Weaver)
* Status: Open
* Priority: Normal
----------------------------------------
### Set Literal vs Javascript Object Punning
There was a proposal for a Set literal here: https://bugs.ruby-lang.org/issues/16989
```ruby
set = { 1, 2, 3 }
```
...but it was brought up that this is similar to the Javascript Object punning, or Object shorthand syntax:
```js
const a = 1, b = 2, c = 3;
const punnedObject = { a, b, c }
// => { a: 1, b: 2, c: 3 }
```
**Proposition**: I believe we should use brackets (`{}`) for a shorthand Hash syntax similar to Javascript.
### Hash Punning
My first proposal in this feature request is Hash punning, or Hash shorthand:
```ruby
a = 1
b = 2
c = 3
{ a:, b:, c: }
# => { a: 1, b: 2, c: 3 }
```
This syntax avoids the ambiguous syntax of empty block (`{}`) versus empty set (`{}`), and with the presence of Symbols it introduces a distinct syntax that would be easier to parse against.
One potential issue would be mixed syntax:
```ruby
{ a:, b: 2 }
# => { a: 1, b: 2 }
```
### Method Punning
This syntax can also be used for keyword argument and method call punning:
```ruby
def method_name(a:, b:, c:)
a + b + c
end
a = 1
b = 2
c = 3
method_name(a:, b:, c:)
# => 6
```
I believe this existing syntax for required keywords gives credence to the idea of introducing punning to Ruby, as it's very similar to existing syntax, and therefor feels "Ruby-like".
### Pattern Matching
This syntax is also already present and used in pattern matching, making it already part of the language:
```ruby
case { x: 1, y: 2 }
in { x:, y: }
{ x:, y: y + 1} # new
else
# ...
end
```
I believe this further justifies the case for punning syntax.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>