Backport #1183
Adding support for the new hash literal syntax
| Status: | Closed | Start date: | 02/20/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | core | |||
| Target version: | Ruby 1.8.8 |
Description
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
Associated revisions
* parse.y: Support for { key: value } -style hash immediates.
[ruby-core:21946][ruby-core:22286]
* keywords: ditto.
History
Updated by nobu (Nobuyoshi Nakada) over 3 years ago
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
Updated by shyouhei (Shyouhei Urabe) about 3 years ago
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.
Updated by nobu (Nobuyoshi Nakada) about 3 years ago
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
Updated by shyouhei (Shyouhei Urabe) about 3 years ago
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.
Updated by shyouhei (Shyouhei Urabe) almost 3 years ago
- File tLABEL.patch added
Updated by shyouhei (Shyouhei Urabe) almost 3 years ago
太古のメールに返信する上に-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 > > >
Updated by shyouhei (Shyouhei Urabe) almost 3 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r24338.
Updated by shyouhei (Shyouhei Urabe) almost 3 years ago
Shyouhei Urabe さんは書きました: > Applied in changeset r24338. とりあえずNEWSは書きましたが、テストはどこに突っ込めばいいんでしょうか... Attachment: signature.asc