Project

General

Profile

Actions

Backport #1183

closed

Adding support for the new hash literal syntax

Added by knu (Akinori MUSHA) about 15 years ago. Updated almost 13 years ago.

Status:
Closed
[ruby-core:22286]

Description

=begin
Attached is a patch for ruby_1_8 which adds support for the new literal syntax for hash and hash style arguments.

However, there needs some more work to retain the use of colon in place of then/do, in order to keep backward compatibility, although it has been deprecated and dropped in 1.9.

knu@daemon[1]% ruby-1.8.7 -ve 'if true: p(1); end'
ruby 1.8.7 (2008-11-11 patchlevel 73) [x86_64-freebsd7]
1
knu@daemon[1]% ruby-1.8 -ve 'if true: p(1); end'
ruby 1.8.7p5000 (2009-02-19 revision 22433) [x86_64-freebsd7]
-e:1: syntax error, unexpected tLABEL
if true: p(1); end
^
-e:1: syntax error, unexpected kEND, expecting $end
=end


Files

label_hash.patch (4.12 KB) label_hash.patch knu (Akinori MUSHA), 02/20/2009 07:17 PM
tLABEL.patch (4.26 KB) tLABEL.patch a patch to implement "label: value" style hash, for 1.8 shyouhei (Shyouhei Urabe), 07/23/2009 03:49 AM
Actions #1

Updated by nobu (Nobuyoshi Nakada) about 15 years ago

=begin
Hi,

At Fri, 20 Feb 2009 19:17:10 +0900,
Akinori MUSHA wrote in [ruby-core:22286]:

However, there needs some more work to retain the use of
colon in place of then/do, in order to keep backward
compatibility, although it has been deprecated and dropped in
1.9.

No such syntax has been defined officially.
No backward compatibility issue.

--
Nobu Nakada

=end

Actions #2

Updated by shyouhei (Shyouhei Urabe) about 15 years ago

=begin
Nobuyoshi Nakada wrote:

Hi,

At Fri, 20 Feb 2009 19:17:10 +0900,
Akinori MUSHA wrote in [ruby-core:22286]:

However, there needs some more work to retain the use of
colon in place of then/do, in order to keep backward
compatibility, although it has been deprecated and dropped in
1.9.

No such syntax has been defined officially.
No backward compatibility issue.

What do you mean here in "official"? because AFAIK there has been no single
line of official syntax definitions so far.

=end

Actions #3

Updated by nobu (Nobuyoshi Nakada) about 15 years ago

=begin
Hi,

At Fri, 20 Feb 2009 20:49:35 +0900,
Urabe Shyouhei wrote in [ruby-core:22289]:

What do you mean here in "official"? because AFAIK there has been no single
line of official syntax definitions so far.

Matz's book and official tutorial[1] mention about "then" but
not ":". Is there any description about such colons?

[1] http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html

--
Nobu Nakada

=end

Actions #4

Updated by shyouhei (Shyouhei Urabe) about 15 years ago

=begin
Nobuyoshi Nakada wrote:

Hi,

At Fri, 20 Feb 2009 20:49:35 +0900,
Urabe Shyouhei wrote in [ruby-core:22289]:

What do you mean here in "official"? because AFAIK there has been no single
line of official syntax definitions so far.

Matz's book and official tutorial[1] mention about "then" but
not ":". Is there any description about such colons?

At least O'Reilly's "Programming Language Ruby" has a detailed description
about it. One of a Matz's book no wonder.

=end

Actions #5

Updated by shyouhei (Shyouhei Urabe) over 14 years ago

=begin

=end

Actions #6

Updated by shyouhei (Shyouhei Urabe) over 14 years ago

=begin
太古のメールに返信する上に-devに振るのですが、これできた気がします。test-allと
かが一応通っていそうです。どんなもんでしょうか。

patchはredmineに貼ってあります。

Akinori MUSHA さんは書きました:

Backport #1183: Adding support for the new hash literal syntax
http://redmine.ruby-lang.org/issues/show/1183

Author: Akinori MUSHA
Status: Open, Priority: Normal
Assigned to: Akinori MUSHA, Category: core, Target version: Ruby 1.8.8

Attached is a patch for ruby_1_8 which adds support for the new literal syntax for hash and hash style arguments.

However, there needs some more work to retain the use of colon in place of then/do, in order to keep backward compatibility, although it has been deprecated and dropped in 1.9.

knu@daemon[1]% ruby-1.8.7 -ve 'if true: p(1); end'
ruby 1.8.7 (2008-11-11 patchlevel 73) [x86_64-freebsd7]
1
knu@daemon[1]% ruby-1.8 -ve 'if true: p(1); end'
ruby 1.8.7p5000 (2009-02-19 revision 22433) [x86_64-freebsd7]
-e:1: syntax error, unexpected tLABEL
if true: p(1); end
^
-e:1: syntax error, unexpected kEND, expecting $end


http://redmine.ruby-lang.org

=end

Actions #7

Updated by shyouhei (Shyouhei Urabe) over 14 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r24338.
=end

Actions #8

Updated by shyouhei (Shyouhei Urabe) over 14 years ago

=begin
Shyouhei Urabe さんは書きました:

Applied in changeset r24338.

とりあえずNEWSは書きましたが、テストはどこに突っ込めばいいんでしょうか...

Attachment: signature.asc
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0